This repository was archived by the owner on Aug 20, 2025. It is now read-only.
Update build_and_test_rust.yaml #3
This file contains hidden or 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: Build | |
| on: | |
| push: | |
| branches: | |
| - rust | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: europe-north1-docker.pkg.dev/${{ secrets.GAR_PROJECT_ID }}/microdata-docker | |
| IMAGE: metadata-service | |
| jobs: | |
| test: | |
| name: cargo test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: rust | |
| - name: Set up Rust (Minimal) | |
| run: rustup toolchain install stable --profile minimal | |
| - run: cargo test --all-features | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: rust | |
| - name: Authenticate to Google Cloud | |
| id: auth | |
| uses: google-github-actions/auth@v1.1.1 | |
| with: | |
| workload_identity_provider: "projects/${{ secrets.GAR_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/gh-actions/providers/gh-actions" | |
| service_account: "gh-actions-microdata@${{ secrets.GAR_PROJECT_ID }}.iam.gserviceaccount.com" | |
| token_format: access_token | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Login to Artifact Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: "oauth2accesstoken" | |
| password: "${{ steps.auth.outputs.access_token }}" | |
| - name: Extract build metadata for Docker | |
| id: build_metadata | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE }} | |
| tags: | | |
| type=raw,value=rust-{{sha}} | |
| type=raw,value=rust-latest | |
| - name: Build and push docker image to Artifact Registry | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| provenance: false | |
| file: Dockerfile | |
| push: true | |
| tags: ${{ steps.build_metadata.outputs.tags }} | |
| labels: ${{ steps.build_metadata.outputs.labels }} | |
| build-args: | | |
| COMMIT_ID=${{ github.sha }} | |
| integration-test: | |
| name: Run Integration test | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Call workflow | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.INTEGRATION_TEST_PAT }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: 'statisticsnorway', | |
| repo: '${{ secrets.INTEGRATION_TEST_REPO }}', | |
| workflow_id: '${{ secrets.INTEGRATION_TEST_WORKFLOW }}.yaml', | |
| ref: 'main' | |
| }) |