Skip to content

Commit 198ce37

Browse files
committed
ci: added ci parameter to shell.nix to enable strict error checking for bash scripts
1 parent 45dfea8 commit 198ce37

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

.gitlab-ci.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ check:lint:
5050
needs: []
5151
script:
5252
- >
53-
nix-shell --run '
53+
nix-shell --arg ci true --run $'
5454
npm run lint;
5555
npm run lint-shell;
5656
'
@@ -82,8 +82,8 @@ check:test-generate:
8282
needs: []
8383
script:
8484
- >
85-
nix-shell --run '
86-
./scripts/check-test-generate.sh > ./tmp/check-test.yml
85+
nix-shell --arg ci true --run $'
86+
./scripts/check-test-generate.sh > ./tmp/check-test.yml;
8787
'
8888
artifacts:
8989
when: always
@@ -124,7 +124,7 @@ build:merge:
124124
# Required for `gh pr create`
125125
- git remote add upstream "$GH_PROJECT_URL"
126126
- >
127-
nix-shell --run '
127+
nix-shell --arg ci true --run $'
128128
gh pr create \
129129
--head staging \
130130
--base master \
@@ -149,7 +149,7 @@ build:dist:
149149
needs: []
150150
script:
151151
- >
152-
nix-shell --run '
152+
nix-shell --arg ci true --run $'
153153
npm run build --verbose;
154154
'
155155
artifacts:
@@ -167,8 +167,8 @@ build:platforms-generate:
167167
needs: []
168168
script:
169169
- >
170-
nix-shell --run '
171-
./scripts/build-platforms-generate.sh > ./tmp/build-platforms.yml
170+
nix-shell --arg ci true --run $'
171+
./scripts/build-platforms-generate.sh > ./tmp/build-platforms.yml;
172172
'
173173
artifacts:
174174
when: always
@@ -210,7 +210,7 @@ build:prerelease:
210210
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
211211
- echo 'Publishing library prerelease'
212212
- >
213-
nix-shell --run '
213+
nix-shell --arg ci true --run $'
214214
npm publish --tag prerelease --access public;
215215
'
216216
after_script:
@@ -391,10 +391,7 @@ integration:prerelease:
391391
script:
392392
- echo 'Publishing application prerelease'
393393
- >
394-
nix-shell --run $'
395-
set -o errexit;
396-
set -o nounset;
397-
set -o pipefail;
394+
nix-shell --arg ci true --run $'
398395
if gh release view "$CI_COMMIT_TAG" --repo "$GH_PROJECT_PATH" >/dev/null; then \
399396
gh release \
400397
upload "$CI_COMMIT_TAG" \
@@ -422,10 +419,7 @@ integration:prerelease:
422419
'
423420
- echo 'Prereleasing container image'
424421
- >
425-
nix-shell --run $'
426-
set -o errexit;
427-
set -o nounset;
428-
set -o pipefail;
422+
nix-shell --arg ci true --run $'
429423
skopeo login \
430424
--username "$CI_REGISTRY_USER" \
431425
--password "$CI_REGISTRY_PASSWORD" \
@@ -469,7 +463,7 @@ integration:merge:
469463
GIT_DEPTH: 0
470464
script:
471465
- >
472-
nix-shell --run '
466+
nix-shell --arg ci true --run $'
473467
printf "Pipeline Succeeded on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
474468
| gh pr comment staging \
475469
--body-file - \
@@ -538,11 +532,11 @@ release:distribution:
538532
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
539533
- echo 'Publishing library & application release'
540534
- >
541-
nix-shell --run $'
535+
nix-shell --arg ci true --run $'
542536
npm publish --access public;
543537
'
544538
- >
545-
nix-shell --run $'
539+
nix-shell --arg ci true --run $'
546540
gh release \
547541
create "$CI_COMMIT_TAG" \
548542
builds/*.closure.gz \
@@ -557,7 +551,7 @@ release:distribution:
557551
'
558552
- echo 'Releasing container image'
559553
- >
560-
nix-shell --run $'
554+
nix-shell --arg ci true --run $'
561555
skopeo login \
562556
--username "$CI_REGISTRY_USER" \
563557
--password "$CI_REGISTRY_PASSWORD" \

shell.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ pkgs ? import ./pkgs.nix {} }:
1+
{ pkgs ? import ./pkgs.nix {}, ci ? false }:
22

33
with pkgs;
44
let
@@ -20,7 +20,15 @@ in
2020
. ./.env
2121
set +o allexport
2222
set -v
23-
23+
${
24+
lib.optionalString ci
25+
''
26+
set -o errexit
27+
set -o nounset
28+
set -o pipefail
29+
shopt -s inherit_errexit
30+
''
31+
}
2432
mkdir --parents "$(pwd)/tmp"
2533
2634
# Built executables and NPM executables

0 commit comments

Comments
 (0)