Skip to content

Commit

Permalink
Update upstream corpus test modification workflow to open an issue on…
Browse files Browse the repository at this point in the history
…ly if one doesn't already exist

Signed-off-by: Patrick Jakubowski <[email protected]>
  • Loading branch information
patjakdev committed Sep 11, 2024
1 parent cfe8c09 commit fca230c
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/corpus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
# push:

jobs:
build:
Check-Upstream:
defaults:
run:
shell: bash
runs-on: ubuntu-latest
if: github.repository == 'cedar-policy/cedar-go'
permissions:
issues: write

steps:
- uses: actions/checkout@v4
Expand All @@ -20,19 +22,33 @@ jobs:

# cmp returns status code 1 if the files differ
- name: Compare
id: compare
run: cmp /tmp/corpus-tests.tar.gz corpus-tests.tar.gz

- name: Notify on Failure
if: failure() && github.event_name == 'schedule'
uses: actions/github-script@v6
if: failure() && steps.compare.outcome == 'failure'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.create({
// Get a list of all open issues labeled with 'upstream-corpus-test'. The documentation for
// listForRepo states that it should only return open issues.
const issues = await github.paginate(github.rest.issues.listForRepo, {
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Upstream Integration Test Corpus Modified',
body: 'The upstream integration test corpus at https://raw.githubusercontent.com/cedar-policy/cedar-integration-tests/main/corpus-tests.tar.gz has been updated. Please integrate the changes into the local copy.'
assignees: ['jmccarthy', 'philhassey', 'patjakdev'],
labels: ['bug']
labels: 'upstream-corpus-test'
})
.then((issues) => {
console.log(`Found ${issues.length} open issues`)
// If one doesn't exist, create it
if (issues.length === 0) {
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Upstream Integration Test Corpus Modified',
body: 'The upstream integration test corpus at https://raw.githubusercontent.com/cedar-policy/cedar-integration-tests/main/corpus-tests.tar.gz has been updated. Please integrate the changes into the local copy.',
assignees: ['jmccarthy', 'philhassey', 'patjakdev'],
labels: ['upstream-corpus-test']
})
}
});

0 comments on commit fca230c

Please sign in to comment.