Skip to content

Commit 7adbc19

Browse files
authored
Merge pull request #3628 from IntersectMBO/feat/nightly-preview-test-run
Feat: nightly preview test run
2 parents c5ff31e + e5d7ce5 commit 7adbc19

File tree

8 files changed

+50
-16
lines changed

8 files changed

+50
-16
lines changed

.github/scripts/register_report.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ if grep -q "$REPORT_NAME" "$PROJECT_DIR/$PROJECT_FILE"; then
1010
echo "Project already exists"
1111
echo "project_exists=true">> $GITHUB_OUTPUT
1212
else
13-
echo "$REPORT_NAME" >> "$PROJECT_DIR/$PROJECT_FILE"
13+
echo "\n$REPORT_NAME" >> "$PROJECT_DIR/$PROJECT_FILE"
1414
echo "project_exists=false">> $GITHUB_OUTPUT
1515
fi

.github/scripts/remove_oldest_report.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22

33
if [ -d "gh-pages/$REPORT_NAME" ]; then
44
cd gh-pages/$REPORT_NAME
5-
# Find the oldest numerical directory
6-
oldest_dir=$(find . -maxdepth 1 -type d -regex './[0-9]+' | sort -n | head -1)
7-
if [ -n "$oldest_dir" ]; then
8-
echo "Removing oldest report directory: $oldest_dir"
9-
rm -rf "$oldest_dir"
5+
6+
# Count the number of numerical directories
7+
dir_count=$(find . -maxdepth 1 -type d -regex './[0-9]+' | wc -l)
8+
9+
if [ "$dir_count" -gt 10 ]; then
10+
# Find the oldest numerical directory
11+
oldest_dir=$(find . -maxdepth 1 -type d -regex './[0-9]+' | sort -V | head -1)
12+
if [ -n "$oldest_dir" ]; then
13+
echo "More than 10 report directories exist. Removing oldest: $oldest_dir"
14+
rm -rf "$oldest_dir"
15+
fi
1016
else
11-
echo "No report directories found to remove"
17+
echo "Only $dir_count report directories exist (threshold: 10). Nothing to remove."
1218
fi
19+
1320
cd ../../
1421
else
1522
echo "Report directory does not exist yet"

.github/workflows/test_backend.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
- "sanchogov.tools/api"
1717
- "staging.govtool.byron.network/api"
1818
- "govtool.cardanoapi.io/api"
19+
- "be.preview.gov.tools"
1920
- "z6b8d2f7a-zca4a4c45-gtw.z937eb260.rustrocks.fr"
2021
- "z78acf3c2-z5575152b-gtw.z937eb260.rustrocks.fr"
2122
- "be.gov.tools"
@@ -28,21 +29,25 @@ on:
2829
- "preview"
2930
- "mainnet"
3031
- "preprod"
32+
3133
workflow_run:
3234
workflows: ["Build and deploy GovTool test stack"]
3335
types: [completed]
3436
branches:
3537
- test
3638
- infra/test-chores
3739

40+
schedule:
41+
- cron: "0 0 * * *" # 12AM UTC
42+
3843
concurrency:
3944
group: ${{ github.workflow }}-${{ github.ref }}
4045
cancel-in-progress: false
4146

4247
jobs:
4348
backend-tests:
4449
runs-on: ubuntu-latest
45-
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
50+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' || github.event.schedule }}
4651
outputs:
4752
start_time: ${{ steps.set-pending-status.outputs.timestamp }}
4853
status: ${{ steps.run-tests.outcome }}
@@ -115,7 +120,7 @@ jobs:
115120
path: gh-pages
116121
repository: ${{vars.GH_PAGES}}
117122
ssh-key: ${{ secrets.DEPLOY_KEY }}
118-
123+
119124
- name: Remove oldest report to save space
120125
if: ${{success()}}
121126
run: |
@@ -128,6 +133,7 @@ jobs:
128133
run: |
129134
chmod +x .github/scripts/register_report.sh
130135
.github/scripts/register_report.sh
136+
131137
- if: steps.register-project.outputs.project_exists != 'true'
132138
uses: JamesIves/github-pages-deploy-action@v4
133139
with:
@@ -191,7 +197,7 @@ jobs:
191197
GITHUB_TOKEN: ${{ github.token }}
192198

193199
env:
194-
BASE_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io/api' }}
195-
REPORT_NAME: govtool-backend
200+
BASE_URL: https://${{github.event.schedule && 'be.preview.gov.tools' || inputs.deployment || 'govtool.cardanoapi.io/api' }}
201+
REPORT_NAME: ${{ github.event.schedule && 'nightly-'}}govtool-backend
196202
GH_PAGES: ${{vars.GH_PAGES}}
197203
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}

.github/workflows/test_integration_playwright.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ on:
3737
- test
3838
- infra/test-chores
3939

40+
schedule:
41+
- cron: "0 0 * * *" # 12AM UTC
42+
4043
concurrency:
4144
group: ${{ github.workflow }}-${{ github.ref }}
4245
cancel-in-progress: false
4346

4447
jobs:
4548
integration-tests:
4649
runs-on: ubuntu-latest
47-
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
50+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' || github.event.schedule }}
4851
outputs:
4952
start_time: ${{ steps.set-pending-status.outputs.timestamp }}
5053
status: ${{ steps.run-test.outcome }}
@@ -103,6 +106,11 @@ jobs:
103106
export BLOCKFROST_API_KEY="${{ secrets.BLOCKFROST_API_KEY_MAINNET }}"
104107
fi
105108
109+
# Set schedule workflow variable
110+
if [[ "$GITHUB_EVENT_NAME" == "schedule" ]]; then
111+
export SCHEDULED_WORKFLOW="true"
112+
fi
113+
106114
npm run test:headless
107115
108116
- name: Upload report
@@ -165,7 +173,7 @@ jobs:
165173
run: |
166174
chmod +x .github/scripts/register_report.sh
167175
.github/scripts/register_report.sh
168-
176+
169177
- if: steps.register-project.outputs.project_exists != 'true'
170178
uses: JamesIves/github-pages-deploy-action@v4
171179
with:
@@ -229,7 +237,7 @@ jobs:
229237
REPORT_NUMBER: ${{ needs.publish-report.outputs.report_number }}
230238
GITHUB_TOKEN: ${{ github.token }}
231239
env:
232-
HOST_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }}
233-
REPORT_NAME: govtool-frontend
240+
HOST_URL: https://${{ github.event.schedule && 'preview.gov.tools' || (inputs.deployment || 'govtool.cardanoapi.io') }}
241+
REPORT_NAME: ${{ github.event.schedule && 'nightly-'}}govtool-frontend
234242
GH_PAGES: ${{vars.GH_PAGES}}
235243
COMMIT_SHA: ${{ github.event.workflow_run.head_sha || github.sha }}

tests/govtool-frontend/playwright/lib/constants/environments.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const environments = {
2828
metadataBucketUrl: `${CARDANO_API_METADATA_HOST_URL}/data`,
2929
lockInterceptorUrl: `${CARDANO_API_METADATA_HOST_URL}/lock`,
3030
ci: process.env.CI,
31+
isScheduled:
32+
(process.env.SCHEDULED_WORKFLOW &&
33+
process.env.SCHEDULED_WORKFLOW == "true") ||
34+
false,
3135
};
3236

3337
export default environments;

tests/govtool-frontend/playwright/lib/helpers/cardano.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,10 @@ export async function getWalletBalance(address: string) {
8585

8686
return balance;
8787
}
88+
89+
export async function skipIfScheduledWorkflow() {
90+
if (environments.isScheduled) {
91+
await allure.description("This test is skipped in scheduled workflow.");
92+
test.skip();
93+
}
94+
}

tests/govtool-frontend/playwright/tests/7-proposal-submission/proposalSubmission.ga.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ProposalSubmissionPage from "@pages/proposalSubmissionPage";
99
import { expect } from "@playwright/test";
1010
import {
1111
skipIfMainnet,
12+
skipIfScheduledWorkflow,
1213
skipIfTemporyWalletIsNotAvailable,
1314
} from "@helpers/cardano";
1415
import { ProposalType } from "@types";
@@ -31,6 +32,7 @@ Object.values(ProposalType).forEach((proposalType, index) => {
3132
page,
3233
browser,
3334
}, testInfo) => {
35+
await skipIfScheduledWorkflow();
3436
test.setTimeout(testInfo.timeout + environments.txTimeOut);
3537

3638
const wallet = await walletManager.popWallet("proposalSubmission");

tests/govtool-frontend/playwright/tests/proposal.setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import walletManager from "lib/walletManager";
99
import { functionWaitedAssert } from "@helpers/waitedLoop";
1010
import { getWalletConfigForFaucet } from "@helpers/index";
1111

12-
const PROPOSAL_WALLETS_COUNT = 5;
12+
const PROPOSAL_WALLETS_COUNT = environments.isScheduled ? 1 : 5;
1313

1414
let govActionDeposit: number;
1515

0 commit comments

Comments
 (0)