Skip to content

Commit 767e40b

Browse files
committed
Separate schemas and framework
1 parent 413bee2 commit 767e40b

File tree

1 file changed

+62
-11
lines changed

1 file changed

+62
-11
lines changed

.circleci/config.yml

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,14 @@ workflows:
4343
- build-modules:
4444
requires:
4545
- build-branch
46+
- build-schemas:
47+
requires:
48+
- build-branch
4649
- merge-build-branch:
4750
requires:
4851
- build-framework
4952
- build-modules
53+
- build-schemas
5054

5155
modules-coverage:
5256
when:
@@ -149,14 +153,6 @@ jobs:
149153
command: |
150154
set -e
151155
./scripts/wasm-framework-ci.sh
152-
- run:
153-
name: Generate schemas
154-
command: |
155-
# Install deps
156-
cargo install cargo-workspaces
157-
cargo install just
158-
# Run script
159-
just schema
160156
- save_cache:
161157
paths:
162158
# Cargo registry
@@ -174,9 +170,7 @@ jobs:
174170
git pull
175171
# Check for wasm changes
176172
git add framework/artifacts --force
177-
# Check for schema changes
178-
git add schema --force
179-
git commit -m 'Update framework WASM & Schemas [skip ci]' || true
173+
git commit -m 'Update framework WASM' || true
180174
git push origin "$CIRCLE_BRANCH-build" || true
181175
- run:
182176
name: Remove temporary branch if it failed during build framework
@@ -245,6 +239,63 @@ jobs:
245239
failure_message: "**${CIRCLE_USERNAME}**'s modules WASM build failed. Please check why! 😭"
246240
webhook: "${DISCORD_STATUS_WEBHOOK}"
247241

242+
build-schemas:
243+
docker:
244+
- image: cimg/rust:1.80.0
245+
resource_class: xlarge
246+
steps:
247+
- setup_remote_docker
248+
- checkout
249+
- run:
250+
name: "Check for newer workflow"
251+
background: true
252+
command: |
253+
while true; do
254+
sleep 5
255+
LATEST_COMMIT=$(git ls-remote $CIRCLE_REPOSITORY_URL | grep "$CIRCLE_BRANCH$" | cut -f 1)
256+
if [ "$LATEST_COMMIT" != "$CIRCLE_SHA1" ]; then
257+
echo "more recent commit to branch, exiting"
258+
# Remove temporary branch
259+
git push origin --delete "$CIRCLE_BRANCH-build" || true
260+
curl -X POST "https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/cancel?circle-token=$CIRCLE_API_TOKEN"
261+
fi
262+
done
263+
- run:
264+
name: Checkout temporary branch
265+
command: |
266+
git fetch origin "$CIRCLE_BRANCH-build"
267+
git checkout "$CIRCLE_BRANCH-build"
268+
- restore_cache:
269+
keys:
270+
- cargocache-v2-build-rust:1.80.0-{{ checksum "framework/Cargo.lock" }}
271+
- run:
272+
name: Generate schemas
273+
command: |
274+
# Install deps
275+
cargo install cargo-workspaces
276+
cargo install just
277+
# Run script
278+
just schema
279+
- run:
280+
name: Commit and push schemas
281+
command: |
282+
git config --global user.name 'CircleCI'
283+
git config --global user.email 'circleci@example.com'
284+
# Pull latest changes
285+
git pull
286+
# Check for schema changes
287+
git add schema --force
288+
git commit -m 'Update Schemas [skip ci]' || true
289+
git push origin "$CIRCLE_BRANCH-build" || true
290+
- run:
291+
name: Remove temporary branch if it failed during build schemas
292+
when: on_fail
293+
command: git push origin --delete "$CIRCLE_BRANCH-build" || true
294+
- discord/status:
295+
fail_only: true
296+
failure_message: "**${CIRCLE_USERNAME}**'s schemas build failed. Please check why! 😭"
297+
webhook: "${DISCORD_STATUS_WEBHOOK}"
298+
248299
merge-build-branch:
249300
docker:
250301
- image: cimg/base:2024.01

0 commit comments

Comments
 (0)