Skip to content

Commit

Permalink
Merge pull request #2102 from skalenetwork/2031/fix-nightly-tests
Browse files Browse the repository at this point in the history
2031/fix nightly tests
  • Loading branch information
DmytroNazarenko authored Feb 13, 2025
2 parents ec2a775 + a40ea1f commit b16f2f0
Showing 1 changed file with 37 additions and 15 deletions.
52 changes: 37 additions & 15 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,68 @@ on:
- cron: '0 0 * * *'

workflow_dispatch:
inputs:
pr_number:
description: 'Specify a PR number to run tests on (optional)'
required: false
type: string

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
- name: Identify Open Non-Draft PRs with Recent Commits (or Specific PR)
id: get-prs
uses: actions/github-script@v6
with:
script: |
const oneDayAgo = new Date();
oneDayAgo.setDate(oneDayAgo.getDate() - 1);
const prNumber = '${{ github.event.inputs.pr_number }}';
const prs = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
});
let prs = [];
const filteredPRs = [];
for (const pr of prs.data) {
if (pr.draft) continue;
if (prNumber) {
// Fetch the specified PR
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: parseInt(prNumber),
});
prs = [pr.data];
} else {
// Fetch all PRs
const allPRs = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
});
prs = allPRs.data.filter(pr => !pr.draft);
}
const filteredPRs = [];
for (const pr of prs) {
// Get commits to check for recent activity
const commits = await github.rest.pulls.listCommits({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
per_page: 100,
});
const recentCommits = commits.data.filter(commit => {
const commitDate = new Date(commit.commit.author.date);
return commitDate >= oneDayAgo;
});
if (recentCommits.length > 0) {
if (recentCommits.length > 0 || prNumber) {
filteredPRs.push({ branch: pr.head.ref, sha: pr.head.sha, number: pr.number });
}
}
Expand All @@ -57,11 +79,11 @@ jobs:
if: ${{ needs.identify-prs.outputs.pr-data != '[]' && needs.identify-prs.outputs.pr-data != '' }}
strategy:
matrix:
pr: ${{fromJson(needs.identify-prs.outputs.pr-data)}}
pr: ${{ fromJson(needs.identify-prs.outputs.pr-data) }}
uses: ./.github/workflows/test-all.yml
with:
branch_name: ${{ matrix.pr.branch }}
sha: ${{ matrix.pr.sha }}
branch_name: ${{ matrix.pr.branch }}
sha: ${{ matrix.pr.sha }}
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

0 comments on commit b16f2f0

Please sign in to comment.