diff --git a/.github/workflows/canary.yaml b/.github/workflows/canary.yaml new file mode 100644 index 0000000..6be55a8 --- /dev/null +++ b/.github/workflows/canary.yaml @@ -0,0 +1,67 @@ +name: Canary Test + +on: + release: + types: [released] + schedule: + - cron: "30 18 * * *" + workflow_dispatch: + + +jobs: + upload: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + name: cache upload (${{ matrix.os }}) + steps: + - name: Create file to cache + run: | + mkdir test-cache + echo "foo" > test-cache/test.txt + - uses: actions/cache@v3 + with: + path: test-cache + key: ${{ matrix.os }}-runner-${{ github.run_number }}-${{ github.run_attempt }} + canary: + needs: upload + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + env: + CacheKey: ${{ matrix.os }}-runner-${{ github.run_number }}-${{ github.run_attempt }} + steps: + - name: checkout repo + uses: actions/checkout@v2 + - name: Install extension + env: + GITHUB_TOKEN: ${{ secrets.DASHBOARD_TOKEN }} + run: gh extensions install actions/gh-actions-cache + - name: List Command + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.REPO_WRITE_TOKEN }} + run: | + cache_found=$(gh actions-cache list --key $CacheKey --limit 100 --branch $GITHUB_REF --order desc --sort created-at | grep $CacheKey) + echo $cache_found + [[ -z "$cache_found" ]] && exit 1 || echo "Cache List Successful" + - name: Delete Command + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.REPO_WRITE_TOKEN }} + run: | + cache_delete=$(gh actions-cache delete $CacheKey --branch $GITHUB_REF --confirm | grep "Deleted 1 cache entry with key") + echo $cache_delete + [[ -z "$cache_delete" ]] && exit 1 || echo "Cache Delete Successful" + - name: Slack Notification on failure + if: failure() + uses: 8398a7/action-slack@a74b761b4089b5d730d813fbedcd2ec5d394f3af + with: + text: actions/gh-actions-cache canary failure + status: ${{ job.status }} + fields: repo,workflow,message,author,action,ref + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}