|
| 1 | +name: Test, Coverage and GraphQL SDL Validation |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + APP_NAME: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + description: "Application name for virtual environment path" |
| 10 | + PYTHON_VERSION: |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + default: "3.10" |
| 14 | + secrets: |
| 15 | + apollo-secret: |
| 16 | + required: true |
| 17 | + description: "AWS Secrets Manager secret ID for Apollo credentials" |
| 18 | + |
| 19 | +jobs: |
| 20 | + test_cov_sdl: |
| 21 | + name: "Pytest, Coverage and Graph SDL" |
| 22 | + runs-on: ubuntu-latest |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + python-version: [${{ inputs.PYTHON_VERSION }}] |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + - name: Set up Python ${{ matrix.python-version }} |
| 30 | + uses: actions/setup-python@v4 |
| 31 | + with: |
| 32 | + python-version: ${{ matrix.python-version }} |
| 33 | + - name: Set up dependencies |
| 34 | + run: ./setup.sh |
| 35 | + shell: bash |
| 36 | + - name: Run unittests |
| 37 | + run: | |
| 38 | + . ~/.venvs/${{ inputs.APP_NAME }}/bin/activate |
| 39 | + pytest --cov=. --cov-report xml |
| 40 | + - name: Pytest coverage comment |
| 41 | + uses: MishaKav/pytest-coverage-comment@main |
| 42 | + with: |
| 43 | + pytest-xml-coverage-path: ./coverage.xml |
| 44 | + title: "Unit Test Coverage Report" |
| 45 | + remove-link-from-badge: true |
| 46 | + - name: Generate SDL |
| 47 | + run: | |
| 48 | + . ~/.venvs/${{ inputs.APP_NAME }}/bin/activate |
| 49 | + strawberry export-schema main_server:schema > schema.graphql |
| 50 | + - name: Upload SDL as artifact |
| 51 | + uses: actions/upload-artifact@v4 |
| 52 | + with: |
| 53 | + name: schema_graphql |
| 54 | + path: ./schema.graphql |
| 55 | + retention-days: 2 |
| 56 | + |
| 57 | + supergraph: |
| 58 | + name: "Validate Subgraph changes" |
| 59 | + runs-on: ubuntu-latest |
| 60 | + strategy: |
| 61 | + matrix: |
| 62 | + python-version: [${{ inputs.PYTHON_VERSION }}] |
| 63 | + env: |
| 64 | + APOLLO_VCS_COMMIT: ${{ github.event.pull_request.head.sha }} |
| 65 | + needs: [test_cov_sdl] |
| 66 | + steps: |
| 67 | + - name: Checkout |
| 68 | + uses: actions/checkout@v4 |
| 69 | + - name: Set up Python ${{ matrix.python-version }} |
| 70 | + uses: actions/setup-python@v4 |
| 71 | + with: |
| 72 | + python-version: ${{ matrix.python-version }} |
| 73 | + - name: Configure AWS Credentials |
| 74 | + uses: aws-actions/configure-aws-credentials@v4 |
| 75 | + with: |
| 76 | + aws-region: us-east-1 |
| 77 | + role-to-assume: ${{ vars.DEV_DEPLOYER_ROLE_IAM }} |
| 78 | + role-session-name: "Apollo-Credentials-${{ vars.ECR_REPO_LABEL }}" |
| 79 | + - name: Pull secrets from AWS |
| 80 | + uses: aws-actions/aws-secretsmanager-get-secrets@v1 |
| 81 | + with: |
| 82 | + secret-ids: | |
| 83 | + ${{ secrets.apollo-secret }} |
| 84 | + parse-json-secrets: true |
| 85 | + - name: Pull SDL generated |
| 86 | + id: pull_sdl |
| 87 | + uses: actions/download-artifact@v4 |
| 88 | + with: |
| 89 | + name: schema_graphql |
| 90 | + path: ./ |
| 91 | + - name: Install Rover |
| 92 | + run: | |
| 93 | + curl -sSL https://rover.apollo.dev/nix/v0.13.0 | sh |
| 94 | + echo "$HOME/.rover/bin" >> $GITHUB_PATH |
| 95 | + - name: Check Changes Against Dev variant |
| 96 | + run: | |
| 97 | + rover subgraph check $DEV_V2_APOLLO_GRAPH --schema ./schema.graphql --background --name ${{ vars.ECR_REPO_LABEL }} |
0 commit comments