github.com/grafana/synthetic-monitoring-agent@v0.64.2/.github/workflows/validate_pr.yaml (about)

     1  name: validate pull request
     2  
     3  on:
     4    pull_request:
     5      branches:
     6        - main
     7  
     8  permissions:
     9    contents: none
    10    packages: none
    11  
    12  jobs:
    13    validate:
    14      name: validate
    15      strategy:
    16        matrix:
    17          runner: [ ubuntu-latest, github-hosted-ubuntu-arm64 ]
    18          include:
    19            - runner: ubuntu-latest
    20              build_catalogue: true
    21      runs-on: ${{ matrix.runner }}
    22  
    23      permissions:
    24        contents: read
    25  
    26      container:
    27        image: ghcr.io/grafana/grafana-build-tools:v1.47.0@sha256:a80098070f2bb1b3c8b74160803c97955c66038a925e8814b91ebbe63f1fd36c
    28        volumes:
    29          # This works as long as we are using self-hosted runners.
    30          #
    31          # Self-hosted runners have this file which is used to configure
    32          # buildkitd. The file is injected when the image is created.
    33          - /etc/buildkitd.toml:/etc/buildkitd.toml
    34      steps:
    35        - name: checkout
    36          uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
    37          with:
    38            fetch-depth: 0
    39            fetch-tags: true
    40            persist-credentials: false
    41  
    42        - name: Set up global git config
    43          run: |
    44            # The directory where the code has been checked out ends up belonging
    45            # to a different user, so git complains about permissions. Indicate
    46            # that it's safe to ignore.
    47            git config --global --add safe.directory '*'
    48  
    49        - name: Restore Go cache
    50          id: restore-go-cache
    51          uses: ./.github/actions/go-cache-restore
    52  
    53        - name: build info
    54          id: build-info
    55          run: |
    56            echo "os=$(go env GOOS)" >> "$GITHUB_OUTPUT"
    57            echo "arch=$(go env GOARCH)" >> "$GITHUB_OUTPUT"
    58  
    59        - name: ensure dependencies are up-to-date
    60          run: |
    61            make deps
    62            scripts/enforce-clean
    63  
    64        - name: version
    65          id: version
    66          run: |
    67            make version
    68            echo "value=$(cat dist/version)" >> "$GITHUB_OUTPUT"
    69  
    70        - name: build
    71          run: make build-native
    72  
    73        - name: Download sm-k6
    74          run: make sm-k6-native
    75  
    76        - name: lint
    77          run: make lint
    78  
    79        - name: test
    80          run: make test
    81  
    82        - name: build packages
    83          run: make package-native
    84  
    85        - name: test docker build (no browser)
    86          uses: grafana/shared-workflows/actions/build-push-to-dockerhub@1acd69f48c01d7aef5f209f94048dfeb789026db # build-push-to-dockerhub/v0.2.0
    87          with:
    88            push: false
    89            cache-from: type=local,src=${{ runner.temp }}/.buildx-cache
    90            cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache,mode=min
    91            platforms: |-
    92              ${{ steps.build-info.outputs.os }}/${{ steps.build-info.outputs.arch }}
    93            tags: |-
    94              type=raw,value=${{ steps.version.outputs.value }}
    95              type=sha,prefix=sha-,format=short
    96              latest
    97            target: release
    98  
    99        - name: test docker build (browser)
   100          uses: grafana/shared-workflows/actions/build-push-to-dockerhub@1acd69f48c01d7aef5f209f94048dfeb789026db # build-push-to-dockerhub/v0.2.0
   101          with:
   102            push: false
   103            cache-from: type=local,src=${{ runner.temp }}/.buildx-cache
   104            cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache,mode=min
   105            platforms: |-
   106              ${{ steps.build-info.outputs.os }}/${{ steps.build-info.outputs.arch }}
   107            tags: |-
   108              type=raw,value=${{ steps.version.outputs.value }}-browser
   109              type=sha,prefix=sha-,suffix=-browser,format=short
   110              latest-browser
   111            target: with-browser
   112  
   113        # Run the runtime catalogue validation once per CI rather than repeating
   114        # the same loaded-image test on both matrix legs.
   115        - name: build browser image for runtime catalogue tests
   116          if: matrix.build_catalogue
   117          uses: grafana/shared-workflows/actions/docker-build-push-image@ef27c620a88acc9f3007f30be5e9407324e8975b # docker-build-push-image/v0.3.0
   118          with:
   119            registries: dockerhub
   120            dockerhub-repository: synthetic-monitoring-agent-runtime-catalogue
   121            push: false
   122            cache-from: type=local,src=${{ runner.temp }}/.buildx-cache
   123            cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache,mode=min
   124            platforms: |-
   125              ${{ steps.build-info.outputs.os }}/${{ steps.build-info.outputs.arch }}
   126            tags: |-
   127              type=raw,value=runtime-catalogue-local
   128            target: with-browser
   129            file: Dockerfile.build
   130            load: true
   131  
   132        - name: build runtime catalogue integration test binary
   133          if: matrix.build_catalogue
   134          run: CGO_ENABLED=0 go test -c -o dist/runtime-catalogue-integration.test ./internal/scraper
   135  
   136        - name: run runtime catalogue integration tests
   137          if: matrix.build_catalogue
   138          # This runs the browser-capable runtime catalogue tests as a best-effort
   139          # integration signal while the job shape is still being proven out.
   140          continue-on-error: true
   141          run: |
   142            docker run --rm \
   143              --entrypoint /catalogue-integration.test \
   144              --user root \
   145              -v "${{ github.workspace }}:/work" \
   146              -v "${{ github.workspace }}/dist/runtime-catalogue-integration.test:/catalogue-integration.test" \
   147              -w /work/internal/scraper \
   148              -e HOME=/tmp \
   149              -e SM_RUNTIME_CATALOGUE_INTEGRATION=1 \
   150              -e K6_PATH=/usr/libexec/sm-k6/k6-v1 \
   151              docker.io/synthetic-monitoring-agent-runtime-catalogue:runtime-catalogue-local \
   152              -test.run TestValidateMetricCatalogueIntegration -test.count=1 -test.v