Run nightly tests #47
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
name: Run nightly tests | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
identify-prs: | |
runs-on: ubuntu-latest | |
outputs: | |
pr-data: ${{ steps.get-prs.outputs.pr-data }} | |
steps: | |
- name: Identify Open Non-Draft PRs with Recent Commits | |
id: get-prs | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const oneDayAgo = new Date(); | |
oneDayAgo.setDate(oneDayAgo.getDate() - 1); | |
const prs = await github.rest.pulls.list({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
state: 'open', | |
}); | |
const filteredPRs = []; | |
for (const pr of prs.data) { | |
if (pr.draft) continue; | |
//const commits = await github.rest.pulls.listCommits({ | |
// owner: context.repo.owner, | |
// repo: context.repo.repo, | |
// pull_number: pr.number, | |
// page: 1, | |
//}); | |
// Get the first page of commits to determine the total number of pages | |
const firstPageCommits = await github.rest.pulls.listCommits({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pr.number, | |
per_page: 100, | |
page: 1, | |
}); | |
const totalCommits = firstPageCommits.headers['x-total-count']; | |
const totalPages = Math.ceil(totalCommits / 100); | |
// Get the last page of commits | |
const lastPageCommits = await github.rest.pulls.listCommits({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pr.number, | |
per_page: 100, | |
page: totalPages, | |
}); | |
const recentCommits = lastPageCommits.data.filter(commit => { | |
const commitDate = new Date(commit.commit.author.date); | |
return commitDate >= oneDayAgo; | |
}); | |
if (recentCommits.length > 0) { | |
filteredPRs.push({ branch: pr.head.ref, sha: pr.head.sha, number: pr.number }); | |
} | |
} | |
console.log("Filtered PRs:", filteredPRs); | |
core.setOutput('pr-data', JSON.stringify(filteredPRs)); | |
run-all-tests: | |
needs: [identify-prs] | |
if: ${{ needs.identify-prs.outputs.pr-data != '[]' && needs.identify-prs.outputs.pr-data != '' }} | |
strategy: | |
matrix: | |
pr: ${{fromJson(needs.identify-prs.outputs.pr-data)}} | |
uses: ./.github/workflows/test-all.yml | |
with: | |
branch_name: ${{ matrix.pr.branch }} | |
sha: ${{ matrix.pr.sha }} | |
secrets: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} |