Skip to content

Commit b3c930f

Browse files
authored
ci(github): Fix windows failures during the build process (#2295)
* ci(github): Split publish into multiple steps; Retry publish 5 times before failing completely * chore: Ignore generated assets
1 parent 15bbde9 commit b3c930f

File tree

5 files changed

+55
-1995
lines changed

5 files changed

+55
-1995
lines changed

.github/workflows/build.yaml

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ jobs:
3232
- name: Checkout
3333
uses: actions/checkout@v2
3434

35+
# So we are not in a detached HEAD state and have a user ready, so that
36+
# lerna can commit later on
37+
- name: Prepare Git
38+
run: |
39+
git switch -c "compass-build-workflow"
40+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
41+
git config --local user.name "github-actions[bot]"
42+
3543
- name: Setup Node.js Environment
3644
uses: actions/[email protected]
3745
with:
@@ -45,9 +53,7 @@ jobs:
4553
run: npm install -g verdaccio
4654

4755
- name: Install Dependencies
48-
run: |
49-
npm install --force
50-
npx lerna run prepare --stream
56+
run: npm install --force
5157

5258
# https://github.community/t/set-path-for-wix-toolset-in-windows-runner/154708/3
5359
- name: Set path for candle.exe and light.exe
@@ -69,29 +75,57 @@ jobs:
6975
rm -rf ./storage
7076
verdaccio --config ./scripts/monorepo/verdaccio.yaml --listen 4873 &
7177
VERDACCIO_PID=$!
72-
npx wait-on -t 15000 http://localhost:4873
73-
74-
# Publish packages and update private packages post publish. We have
75-
# to manually run our update script as we can't use git-tag-version in
76-
# CI environment (so version lifecycle is not triggered) and lerna
77-
# doesn't bump private packages on canary publish because reasons
78-
# (see https://github.com/lerna/lerna/issues/2206#issuecomment-521421420)
79-
#
80-
# Running this with a concurrency = 1 with the hopes that zlib on
81-
# windows will not fail that often during release
82-
npx lerna publish prerelease \
83-
--concurrency 1 \
84-
--preid pr \
85-
--canary \
78+
npx wait-on -t 15000 "$npm_config_registry"
79+
80+
nice_hash=$(git rev-parse --short "$GITHUB_SHA")
81+
82+
npx lerna version prerelease \
83+
--preid "pr$nice_hash" \
8684
--no-push \
87-
--no-git-tag-version \
88-
--no-git-reset \
85+
--no-private \
8986
--force-publish "*" \
9087
--yes
91-
npm run version -- --no-stage --no-package-lock
88+
89+
# We will run prepare manually to isolate the flakiest part of the
90+
# process which is publishing
91+
npx lerna run prepare --stream
92+
93+
# Publish process seems to be pretty flaky on Windows so we are
94+
# retrying it up to 5 times before bailing
95+
n=0
96+
exitcode=0
97+
until [ "$n" -ge 5 ]
98+
do
99+
echo ""
100+
echo "Attempting to publish packages ($((n+1))/5) ..."
101+
echo ""
102+
exitcode=0
103+
npx lerna publish from-package \
104+
--ignore-scripts \
105+
--registry "$npm_config_registry" \
106+
--yes && break
107+
exitcode=$?
108+
# If we failed, lerna might've left some changes in the history,
109+
# this needs to be cleaned up before we can retry
110+
git reset HEAD --hard
111+
n=$((n+1))
112+
sleep 1
113+
done
114+
115+
if [ "$exitcode" -gt 0 ]
116+
then
117+
echo ""
118+
echo "Failed to publish packages"
119+
echo ""
120+
# Clean-up background verdaccio process
121+
kill $VERDACCIO_PID
122+
# If we couldn't publish, exit with last publish command exit code
123+
exit $exitcode
124+
fi
92125
93126
# Setting debug before this line breaks plugins build process
94127
export DEBUG=hadron*,mongo*,electron*
128+
95129
npm run release-evergreen
96130
97131
# Clean-up background verdaccio process

packages/hadron-document/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ coverage
77
.idea/
88
*.iml
99
.nvmrc
10+
lib

0 commit comments

Comments
 (0)