Skip to content

Commit 6450545

Browse files
authored
Merge pull request #4192 from bcgov/chore-fix-nightly-build-schemaspy-and-happo
Fix nightly build schemaspy and happo
2 parents a159bc9 + 869d438 commit 6450545

3 files changed

Lines changed: 64 additions & 6 deletions

File tree

.github/workflows/schemaspy.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,10 @@ jobs:
2727
--health-retries 5
2828
ports:
2929
- 5432:5432
30-
timeout-minutes: 10
30+
timeout-minutes: 20
3131
steps:
3232
- uses: actions/checkout@v6
3333
name: checkout code
34-
with:
35-
sparse-checkout: |
36-
bc_obps/
3734
- name: vars
3835
id: vars
3936
shell: bash

.github/workflows/test-nx-project-e2e.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ jobs:
118118
HAPPO_API_SECRET: ${{ github.event_name == 'schedule' && '' || secrets.HAPPO_API_SECRET }}
119119
HAPPO_PROJECT: cas-${{ inputs.nx_project }}
120120
SMTP_CONNECTION_STRING: smtp://@localhost:1025
121-
run: DEBUG=pw:api yarn nx run "$NX_PROJECT":e2e:ci -- --project=chromium
121+
run: DEBUG=pw:api yarn nx run "$NX_PROJECT":${{ github.event_name == 'schedule' && 'e2e' || 'e2e:ci' }} -- --project=chromium
122122
working-directory: ./bciers
123123

124124
# # Reports weren't being used regularly though leaving this in here for debugging purposes.
@@ -159,7 +159,7 @@ jobs:
159159

160160
# Call Happo api and skip the project if it wasn't affected
161161
happo-skip-not-affected:
162-
if: ${{ !inputs.is_nx_affected && github.ref_name != 'develop' && github.ref_name != 'main' && github.head_ref != 'develop' && github.head_ref != 'main' || github.event_name == 'schedule' }}
162+
if: ${{ !inputs.is_nx_affected && github.ref_name != 'develop' && github.ref_name != 'main' && github.head_ref != 'develop' && github.head_ref != 'main' && github.event_name != 'schedule' }}
163163
runs-on: ubuntu-latest
164164
steps:
165165
- uses: actions/checkout@v6
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Testing GitHub Actions Workflows Before Merging
2+
3+
When modifying reusable or scheduled workflows (e.g., `nightly.yaml`, `schemaspy.yaml`), you often can't test changes directly because:
4+
5+
- **Scheduled workflows** (`on: schedule`) always run from the default branch.
6+
- **`workflow_dispatch`** only works for workflows that already exist on the default branch.
7+
- **Reusable workflows** (`on: workflow_call`) can't be triggered directly.
8+
9+
## Recommended Approach: Temporary Push-Triggered Workflow
10+
11+
Create a temporary workflow file on your feature branch that triggers on `push` and calls the reusable workflow you're testing.
12+
13+
### 1. Create the temporary workflow
14+
15+
Add a file like `.github/workflows/test-my-fix.yaml`:
16+
17+
```yaml
18+
# Temporary workflow - delete before merging.
19+
name: Test My Fix
20+
21+
on:
22+
push:
23+
branches:
24+
- my-feature-branch
25+
26+
jobs:
27+
test-job:
28+
uses: ./.github/workflows/the-reusable-workflow.yaml
29+
secrets: inherit
30+
```
31+
32+
### 2. Commit and push
33+
34+
Push the temporary workflow along with your fixes. The workflow runs automatically on push, using the reusable workflow files **from your branch** (not from `develop`).
35+
36+
### 3. Check results
37+
38+
**Using the GitHub UI:**
39+
40+
1. Go to the repository on GitHub.
41+
2. Click the **Actions** tab.
42+
3. Find your workflow name (e.g., "Test My Fix") in the left sidebar.
43+
4. Click into the run to see step-by-step logs and status.
44+
5. If a run was canceled by a concurrent push, click **Re-run all jobs** to retry.
45+
46+
**Using the GitHub CLI (optional):**
47+
48+
```bash
49+
gh run list --workflow=test-my-fix.yaml
50+
gh run watch
51+
```
52+
53+
### 4. Clean up
54+
55+
Delete the temporary workflow file before merging your PR.
56+
57+
## Limitations
58+
59+
- **`github.event_name`** will be `push`, not `schedule`. Conditionals that check for `schedule` (e.g., disabling Happo) won't activate. For those, verify the logic by reading the code; the conditional behavior itself is deterministic.
60+
- **Concurrency settings** in the reusable workflow may cancel runs if you push multiple times quickly. Wait for a run to finish or re-run from the Actions tab.
61+
- **Timeouts** from the reusable workflow still apply. If a full checkout replaces a sparse checkout, you may need to increase the timeout.

0 commit comments

Comments
 (0)