dynamically discover smoke tests #271
Workflow file for this run
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
# Runs all ecosystems cached and concurrently. | |
name: Smoke | |
on: | |
workflow_dispatch: | |
pull_request: | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
suites: | |
runs-on: ubuntu-latest | |
steps: | |
- id: gather | |
run: | | |
URL="https://api.github.com/repos/dependabot/smoke-tests/contents/tests" | |
DATA="$(gh api $URL | jq -r '.[].name' | sed 's/smoke-//' | sed 's/.yaml$//' | jq -R | jq -sc)" | |
echo "suite=$DATA" >> $GITHUB_OUTPUT | |
outputs: | |
suites: ${{ steps.gather.outputs.suite }} | |
smoke: | |
runs-on: ubuntu-latest | |
needs: suites | |
strategy: | |
fail-fast: false | |
matrix: | |
suite: ${{ fromJSON(needs.suites.outputs.suites) }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.20.5 | |
# Download the Proxy cache. The job is ideally 100% cached so no real calls are made. | |
- name: Download cache | |
run: | | |
gh run download --repo dependabot/smoke-tests --name cache-${{ matrix.suite }} --dir cache | |
- name: ${{ matrix.suite }} | |
env: | |
LOCAL_GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -o pipefail | |
URL=https://api.github.com/repos/dependabot/smoke-tests/contents/tests/smoke-${{ matrix.suite }}.yaml | |
curl $(gh api $URL --jq .download_url) -o smoke.yaml | |
go run cmd/dependabot/dependabot.go test \ | |
-f=smoke.yaml \ | |
-o=result.yaml \ | |
--cache=cache \ | |
--timeout 20m \ | |
2>&1 | tee -a log.txt | |
- name: Diff | |
if: always() | |
continue-on-error: true | |
run: diff --ignore-space-change smoke.yaml result.yaml && echo "Contents are identical" || exit 0 | |
- name: Create summary | |
run: tail -n100 log.txt | grep -P '\d+/\d+ calls cached \(\d+%\)' >> $GITHUB_STEP_SUMMARY |