Skip to content

Commit a424e76

Browse files
Add pre-publish smoke test (#369)
* Add scaffolding for smoke tests * Impelement percentile based smoke test * Add changes from PR testing * fix spelling * Add newline * Update needs
1 parent 36de722 commit a424e76

File tree

1 file changed

+56
-3
lines changed

1 file changed

+56
-3
lines changed

.github/workflows/main.yml

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
name: Gatsby Publish
22

3+
env:
4+
DELTA_THRESHOLD: .90
5+
36
on:
47
push:
58
branches:
69
- main
10+
711

812
jobs:
9-
build:
13+
publish-smoke-test:
1014
runs-on: ubuntu-latest
1115
steps:
1216
- uses: actions/checkout@v1
@@ -15,5 +19,54 @@ jobs:
1519
GH_API_KEY: ${{ secrets.GITHUB_TOKEN }}
1620
with:
1721
access-token: ${{ secrets.demo }}
18-
deploy-branch: gh-pages
19-
# gatsby-args: --prefix-paths
22+
deploy-branch: smoke-test
23+
verify-smoke-test:
24+
runs-on: ubuntu-latest
25+
needs: publish-smoke-test
26+
steps:
27+
- name: Checkout Smoke Test Branch
28+
uses: actions/checkout@v3
29+
with:
30+
path: smoke-test
31+
ref: smoke-test
32+
- name: Calculate total lines in smoke-test branch
33+
run: |
34+
export ST_LC=$(find ./smoke-test -type f -print0 | wc -l --files0=- | tail -n 1 | cut -d ' ' -f 1)
35+
echo $ST_LC
36+
echo "SMOKE_TEST_LINE_COUNT=$ST_LC" >> $GITHUB_ENV
37+
- name: Checkout Published Branch
38+
uses: actions/checkout@v3
39+
with:
40+
path: published
41+
ref: gh-pages
42+
- name: Calculate total lines in published branch
43+
run: |
44+
export PUB_LC=$(find ./published -type f -print0 | wc -l --files0=- | tail -n 1 | cut -d ' ' -f 1)
45+
echo $PUB_LC
46+
echo "PUBLISHED_LINE_COUNT=$PUB_LC" >> $GITHUB_ENV
47+
- name: Generate percentile diff
48+
run: |
49+
export PERCENTILE_DIFF=$(bc<<<"scale=2;${{ env.SMOKE_TEST_LINE_COUNT}} / ${{ env.PUBLISHED_LINE_COUNT }}")
50+
echo $PERCENTILE_DIFF
51+
if [ 1 -eq $(bc<<<"$PERCENTILE_DIFF < ${{ env.DELTA_THRESHOLD }}") ]; then
52+
exit 1
53+
else
54+
exit 0
55+
fi
56+
57+
publish-live:
58+
needs: verify-smoke-test
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v3
62+
with:
63+
ref: gh-pages
64+
- name: merge commit push
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.demo }}
67+
run: |
68+
git config --global user.name 'Gatsby Publish Workflow'
69+
git config --global user.email '[email protected]'
70+
git fetch --all
71+
git reset --hard origin/smoke-test
72+
git push -f origin gh-pages

0 commit comments

Comments
 (0)