Data Service Generator E2E Test #11
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: Data Service Generator E2E Test | |
on: | |
# schedule: | |
# - cron: '0 1 * * *' | |
workflow_dispatch: | |
inputs: | |
ecr_tag: | |
description: 'ECR container tag' | |
required: true | |
default: 'next' | |
jobs: | |
prepare-test-cases: | |
runs-on: ubuntu-latest | |
outputs: | |
test-cases: ${{ steps.set-test-cases.outputs.test-cases }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- id: set-test-cases | |
name: Generate matrix for test cases | |
run: | | |
echo "test-cases=$(find test-cases -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT | |
build-and-run-generated-code: | |
runs-on: ubuntu-latest | |
needs: prepare-test-cases | |
strategy: | |
fail-fast: false | |
matrix: | |
test-cases: ${{fromJson(needs.prepare-test-cases.outputs.test-cases)}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: "package.json" | |
cache: "npm" | |
cache-dependency-path: "package-lock.json" | |
- name: Install dependencies | |
run: npm ci | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Run container | |
run: | | |
docker run -v $(pwd):/data --env-file dsg.env \ | |
-e BUILD_SPEC_PATH=/data/test-cases/${MATRIX_TEST_CASES}/input.json \ | |
-e BUILD_OUTPUT_PATH=/data/test-cases/${MATRIX_TEST_CASES}/generated \ | |
-w /workspace/packages/data-service-generator \ | |
${AWS_ACCOUNT_OPS_ID}.dkr.ecr.us-east-1.amazonaws.com/data-service-generator:${DSG_IMAGE_TAG} \ | |
sh -c "node ./src/main.js" | |
env: | |
AWS_ACCOUNT_OPS_ID: ${{ vars.AWS_ACCOUNT_OPS_ID }} | |
DSG_IMAGE_TAG: ${{ github.event.inputs.ecr_tag }} | |
MATRIX_TEST_CASES: ${{ matrix.test-cases }} | |
- name: Check if directory exists | |
run: | | |
if [ ! -d test-cases/${{ matrix.test-cases }}/generated/ ]; then | |
echo "Directory test-cases/${{ matrix.test-cases }}/generated/ does not exist." | |
exit 1 | |
fi | |
- name: Run generated code | |
run: | | |
cd test-cases/${{ matrix.test-cases }}/generated/server | |
npm run compose:up | |
- name: Run e2e tests | |
run: npm run e2e:test | |