* chore: Improve CI workflow * Made a new pre-merge flow that runs the builds and e2e * Refactored back into 1 file * Adding another condition for checking the ready-for-e2e * syntax * More syntax * Change e2e-required to only run when ready so it doesn't fail * A different attempt at getting the ready-for-e2e label * Supporting PRs and workflow_dispatch * logging the branch * hardcoding to test * Trying the rest call * Added logging * Check for the label in the same step * More logging * Added job-level output * Reverted back to 'true' * Moved the e2e required check into the main required check * More logging * Peeling the branch off of the ref * Fix the ref * Trying a separate workflow for labeling * Updated name for the labeled file * Checking label events to avoid unnecessary runs * Got rid of the extra check to see if required should run * Upgraded old actions running Node 16 * Updated the pre-reqs for running jobs * Removed the dependency of API builds before starting E2E suites * Removed extra production build used by analyze job * Fixed the run-e2e check * Using the pull request object when available * Checking for null PR * Added check for no event --------- Co-authored-by: Joe Au-Yeung <[email protected]>
179 lines
6.3 KiB
YAML
179 lines
6.3 KiB
YAML
name: PR Update
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, synchronize, reopened, labeled]
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
changes:
|
|
name: Detect changes
|
|
runs-on: buildjet-2vcpu-ubuntu-2204
|
|
permissions:
|
|
pull-requests: read
|
|
outputs:
|
|
has-files-requiring-all-checks: ${{ steps.filter.outputs.has-files-requiring-all-checks }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: ./.github/actions/dangerous-git-checkout
|
|
- uses: dorny/paths-filter@v3
|
|
id: filter
|
|
with:
|
|
filters: |
|
|
has-files-requiring-all-checks:
|
|
- "!(**.md|.github/CODEOWNERS)"
|
|
|
|
check-label:
|
|
runs-on: buildjet-2vcpu-ubuntu-2204
|
|
name: Check for E2E label
|
|
outputs:
|
|
run-e2e: ${{ steps.check-if-pr-has-label.outputs.run-e2e == 'true' && (github.event_name != 'labeled' || (github.event_name == 'labeled' && github.event.label.name == 'ready-for-e2e')) }}
|
|
run-jobs: ${{ github.event_name != 'labeled' }}
|
|
steps:
|
|
- name: Get PR from branch name
|
|
id: check-if-pr-has-label
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
let pr;
|
|
if (github.event && github.event.pull_request) {
|
|
const response = await github.rest.pulls.get({
|
|
owner: github.context.repo.owner,
|
|
repo: github.context.repo.repo,
|
|
pull_number: github.event.pull_request.number
|
|
});
|
|
|
|
pr = response.data;
|
|
} else {
|
|
const ref = '${{ github.ref }}';
|
|
const branch = ref.replace('refs/heads/', '');
|
|
console.log(ref);
|
|
console.log(branch);
|
|
const response = await github.rest.pulls.list({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
state: 'open',
|
|
head: `${context.repo.owner}:${branch}`
|
|
});
|
|
|
|
if (response.data.length > 0) {
|
|
pr = response.data[0];
|
|
} else {
|
|
core.setOutput('run-e2e', false);
|
|
console.log('No PR found matching the branch');
|
|
}
|
|
}
|
|
|
|
if (!pr) {
|
|
console.log('No PR found');
|
|
return;
|
|
}
|
|
|
|
const labels = pr.labels.map(label => label.name);
|
|
console.log('PR #', pr.number);
|
|
if (labels.includes('ready-for-e2e')) {
|
|
core.setOutput('run-e2e', true);
|
|
console.log('Found the label');
|
|
} else {
|
|
core.setOutput('run-e2e', false);
|
|
console.log('Did not find the label');
|
|
}
|
|
|
|
type-check:
|
|
name: Type check
|
|
needs: [changes, check-label]
|
|
if: ${{ needs.check-label.outputs.run-jobs == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/check-types.yml
|
|
secrets: inherit
|
|
|
|
lint:
|
|
name: Linters
|
|
needs: [changes, check-label]
|
|
if: ${{ needs.check-label.outputs.run-jobs == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/lint.yml
|
|
secrets: inherit
|
|
|
|
unit-test:
|
|
name: Tests
|
|
needs: [changes, check-label]
|
|
if: ${{ needs.check-label.outputs.run-jobs == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/unit-tests.yml
|
|
secrets: inherit
|
|
|
|
integration-test:
|
|
name: Tests
|
|
needs: [changes, check-label]
|
|
if: ${{ needs.check-label.outputs.run-jobs == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/integration-tests.yml
|
|
secrets: inherit
|
|
|
|
build-api-v1:
|
|
name: Production builds
|
|
needs: [changes, check-label]
|
|
if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/api-v1-production-build.yml
|
|
secrets: inherit
|
|
|
|
build-api-v2:
|
|
name: Production builds
|
|
needs: [changes, check-label]
|
|
if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/api-v2-production-build.yml
|
|
secrets: inherit
|
|
|
|
build:
|
|
name: Production builds
|
|
needs: [changes, check-label]
|
|
if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/production-build-without-database.yml
|
|
secrets: inherit
|
|
|
|
e2e:
|
|
name: Tests
|
|
needs: [changes, check-label, build]
|
|
if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/e2e.yml
|
|
secrets: inherit
|
|
|
|
e2e-app-store:
|
|
name: Tests
|
|
needs: [changes, check-label, build]
|
|
if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/e2e-app-store.yml
|
|
secrets: inherit
|
|
|
|
e2e-embed:
|
|
name: Tests
|
|
needs: [changes, check-label, build]
|
|
if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/e2e-embed.yml
|
|
secrets: inherit
|
|
|
|
e2e-embed-react:
|
|
name: Tests
|
|
needs: [changes, check-label, build]
|
|
if: ${{ needs.check-label.outputs.run-e2e == 'true' && needs.changes.outputs.has-files-requiring-all-checks == 'true' }}
|
|
uses: ./.github/workflows/e2e-embed-react.yml
|
|
secrets: inherit
|
|
|
|
analyze:
|
|
name: Analyze Build
|
|
needs: [build]
|
|
uses: ./.github/workflows/nextjs-bundle-analysis.yml
|
|
secrets: inherit
|
|
|
|
required:
|
|
needs: [changes, lint, type-check, unit-test, integration-test, check-label, build, build-api-v1, build-api-v2, e2e, e2e-embed, e2e-embed-react, e2e-app-store]
|
|
if: ${{ needs.check-label.outputs.run-e2e == 'true' }}
|
|
runs-on: buildjet-2vcpu-ubuntu-2204
|
|
steps:
|
|
- name: fail if conditional jobs failed
|
|
if: needs.changes.outputs.has-files-requiring-all-checks == 'true' && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled'))
|
|
run: exit 1
|