Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several improvements to the upstream corpus test workflow #32

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']
})
}
});
Loading