Add Config CLI to the connector #64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous Integration | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
unit_tests: | |
name: Run NDC tests | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout (GitHub) | |
uses: actions/checkout@v3 | |
with: | |
path: cosmos | |
- name: Log in to GitHub Container Registry 📦 | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Start Azure Cosmos DB emulator | |
run: | |
docker run --detach --publish 8081:8081 --publish 10250-10255:10250-10255 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest | |
- name: Setup database | |
run: | | |
check_port() { | |
nc -z localhost 8081 | |
return $? | |
} | |
timeout_duration=$((2 * 60)) # 2 minutes | |
# Start time | |
start_time=$(date +%s) | |
until check_port || [ $(( $(date +%s) - start_time )) -ge $timeout_duration ]; do | |
echo "The emulator is not yet available, waiting..." | |
sleep 1 | |
done | |
if check_port; then | |
echo "Port 8081 is now open!" | |
# Sleep for 120 seconds, because there is no deterministic way | |
# the emulator provides to check if it is up and running :( | |
sleep 120 | |
sudo curl -k --retry 10 https://localhost:8081/_explorer/emulator.pem > ~/emulatorcert.crt | |
sudo cp ~/emulatorcert.crt /usr/local/share/ca-certificates/ | |
sudo update-ca-certificates | |
cd cosmos/script | |
npm install --save @azure/cosmos | |
npm install --save @azure/identity | |
node app.js | |
else | |
echo "Timeout: Port 8081 is still not available after $timeout_duration seconds." | |
exit 1 | |
fi | |
- name: Build connector | |
run: | | |
cd cosmos | |
npm install --save @azure/cosmos | |
npm run build | |
- name: Generate the connector configuration | |
run: | | |
cd cosmos | |
chmod +x ./dist/cli/index.js | |
export AZURE_COSMOS_KEY=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw== | |
export AZURE_COSMOS_ENDPOINT=https://127.0.0.1:8081/ | |
export AZURE_COSMOS_DB_NAME=ConnectorTest | |
./dist/cli/index.js update --allow-self-signed-certificate true | |
- name: Start connector | |
run: | | |
cd cosmos | |
export HASURA_CONFIGURATION_DIRECTORY="." | |
npm run start serve --configuration . | |
- name: Checkout ndc-spec | |
uses: actions/checkout@v3 | |
with: | |
repository: hasura/ndc-spec | |
path: ndc-spec | |
- name: Run ndc-test | |
working-directory: ndc-spec | |
run: cargo run --bin ndc-test -- replay --endpoint http://0.0.0.0:8080 --snapshots-dir ../cosmos/ndc-test-snapshots |