Skip to content

Commit 83eaba1

Browse files
authored
Merge pull request #4382 from snyk/feat/HEAD-3_deployment_tests
feat: improve deployment testing
2 parents 8f92462 + 1750ebd commit 83eaba1

File tree

5 files changed

+114
-47
lines changed

5 files changed

+114
-47
lines changed

.circleci/config.yml

Lines changed: 59 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,6 @@ jobs:
547547
- attach_workspace:
548548
at: .
549549
- setup_npm
550-
- run:
551-
name: Validating NPM artifacts
552-
command: ./release-scripts/validate-npm-artifacts.sh
553550
- run:
554551
name: Copy Windows cliv2 binaries to binary-releases staging area
555552
command: |
@@ -592,44 +589,55 @@ jobs:
592589
root: .
593590
paths:
594591
- binary-releases
595-
release:
592+
pre-release:
596593
executor: docker-node
597594
steps:
598595
- checkout
599596
- attach_workspace:
600597
at: .
601598
- setup_npm
599+
- aws-cli/install:
600+
version: << pipeline.parameters.aws_version >>
602601
- run:
603-
name: Validating artifacts
604-
command: ./release-scripts/validate-checksums.sh
602+
name: Pre-Publishing
603+
command: make release-pre
604+
- run:
605+
name: Handling failed release
606+
command: ./release-scripts/handle-failed-release.sh
607+
when: on_fail
608+
609+
test-release:
610+
parameters:
611+
executor:
612+
type: string
613+
executor: << parameters.executor >>
614+
steps:
615+
- checkout
616+
- attach_workspace:
617+
at: .
618+
- run:
619+
name: Validating NPM artifacts
620+
command: bash ./release-scripts/validate-npm-artifacts.sh
621+
- run:
622+
name: Handling failed release
623+
command: bash ./release-scripts/handle-failed-release.sh
624+
when: on_fail
625+
626+
release:
627+
executor: docker-node
628+
steps:
629+
- checkout
630+
- attach_workspace:
631+
at: .
632+
- setup_npm
605633
- gh/setup:
606634
token: GH_TOKEN
607635
version: << pipeline.parameters.gh_version >>
608636
- aws-cli/install:
609637
version: << pipeline.parameters.aws_version >>
610638
- run:
611-
name: Ensure master branch
612-
command: |
613-
if [ "$CIRCLE_BRANCH" != "master" ]; then
614-
echo "Release must be on 'master' branch."
615-
exit 1
616-
fi
617-
- run:
618-
name: Ensure not already released
619-
command: |
620-
if git describe --contains --tags; then
621-
echo "This commit has already been released."
622-
exit 1
623-
fi
624-
- run:
625-
name: Publishing npm packages
626-
command: |
627-
npm publish ./binary-releases/snyk-fix.tgz
628-
npm publish ./binary-releases/snyk-protect.tgz
629-
npm publish ./binary-releases/snyk.tgz
630-
- run:
631-
name: Publishing artifacts
632-
command: ./release-scripts/upload-artifacts.sh
639+
name: Publishing
640+
command: make release-final
633641
- run:
634642
name: Handling failed release
635643
command: ./release-scripts/handle-failed-release.sh
@@ -1095,11 +1103,33 @@ workflows:
10951103
branches:
10961104
only:
10971105
- master
1106+
- pre-release:
1107+
name: Pre-Release
1108+
context: nodejs-app-release
1109+
requires:
1110+
- Release?
1111+
filters:
1112+
branches:
1113+
only:
1114+
- master
1115+
- test-release:
1116+
name: Test Release (<< matrix.executor >>)
1117+
matrix:
1118+
parameters:
1119+
executor: ['linux', 'win/default', 'macos']
1120+
requires:
1121+
- Pre-Release
1122+
filters:
1123+
branches:
1124+
only:
1125+
- master
10981126
- release:
10991127
name: Release
11001128
context: nodejs-app-release
11011129
requires:
1102-
- Release?
1130+
- Test Release (linux)
1131+
- Test Release (win/default)
1132+
- Test Release (macos)
11031133
filters:
11041134
branches:
11051135
only:

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,18 @@ build:
160160
clean:
161161
@cd $(EXTENSIBLE_CLI_DIR) && $(MAKE) clean-full
162162
$(MAKE) clean-prepack
163+
164+
# targets responsible for the CLI release
165+
.PHONY: release-pre
166+
release-pre:
167+
@echo "-- Validating repository"
168+
@./release-scripts/validate-repository.sh
169+
@echo "-- Validating artifacts"
170+
@./release-scripts/validate-checksums.sh
171+
@echo "-- Publishing to S3 /version"
172+
@./release-scripts/upload-artifacts.sh version
173+
174+
.PHONY: release-final
175+
release-final:
176+
@echo "-- Publishing"
177+
@./release-scripts/upload-artifacts.sh latest github npm

release-scripts/upload-artifacts.sh

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,38 @@ declare -a StaticFiles=(
2323

2424
VERSION_TAG="v$(cat binary-releases/version)"
2525

26-
# Upload files to the GitHub release
27-
gh release create "${VERSION_TAG}" "${StaticFiles[@]}" \
28-
--target "${CIRCLE_SHA1}" \
29-
--title "${VERSION_TAG}" \
30-
--notes-file binary-releases/RELEASE_NOTES.md
26+
if [ ${#} == 0 ]; then
27+
echo "No upload target defined!"
28+
exit 1
29+
fi
3130

32-
# Upload files to the versioned folder
33-
for filename in "${StaticFiles[@]}"; do
34-
aws s3 cp "${filename}" s3://"${PUBLIC_S3_BUCKET}"/cli/"${VERSION_TAG}"/
35-
done
31+
for arg in "${@}"; do
32+
target="${arg}"
33+
if [ "${arg}" == "version" ]; then
34+
target="${VERSION_TAG}"
35+
fi
36+
echo "Uploading to ${target}"
3637

37-
# Upload files to the /latest folder
38-
for filename in "${StaticFiles[@]}"; do
39-
aws s3 cp "${filename}" s3://"${PUBLIC_S3_BUCKET}"/cli/latest/
40-
done
38+
# Upload files to the GitHub release
39+
if [ "${arg}" == "github" ]; then
40+
gh release create "${VERSION_TAG}" "${StaticFiles[@]}" \
41+
--target "${CIRCLE_SHA1}" \
42+
--title "${VERSION_TAG}" \
43+
--notes-file binary-releases/RELEASE_NOTES.md
4144

42-
aws s3 cp "binary-releases/release.json" s3://"${PUBLIC_S3_BUCKET}"/cli/"${VERSION_TAG}"/
43-
aws s3 cp "binary-releases/version" s3://"${PUBLIC_S3_BUCKET}"/cli/"${VERSION_TAG}"/
44-
aws s3 cp "binary-releases/release.json" s3://"${PUBLIC_S3_BUCKET}"/cli/latest/
45-
aws s3 cp "binary-releases/version" s3://"${PUBLIC_S3_BUCKET}"/cli/latest/
45+
# Upload files to npm
46+
elif [ "${arg}" == "npm" ]; then
47+
npm publish ./binary-releases/snyk-fix.tgz
48+
npm publish ./binary-releases/snyk-protect.tgz
49+
npm publish ./binary-releases/snyk.tgz
50+
51+
# Upload files to S3 bucket
52+
else
53+
for filename in "${StaticFiles[@]}"; do
54+
aws s3 cp "${filename}" s3://"${PUBLIC_S3_BUCKET}"/cli/"${target}"/
55+
done
56+
57+
aws s3 cp "binary-releases/release.json" s3://"${PUBLIC_S3_BUCKET}"/cli/"${target}"/
58+
aws s3 cp "binary-releases/version" s3://"${PUBLIC_S3_BUCKET}"/cli/"${target}"/
59+
fi
60+
done

release-scripts/validate-npm-artifacts.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ echo 'Running "npm install binary-releases/snyk.tgz"...'
1010
npm install $releaseTar
1111

1212
echo 'Validating "snyk" command succeeds...'
13-
./node_modules/snyk/bin/snyk
13+
./node_modules/snyk/bin/snyk -d
1414

1515
popd
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if git describe --contains --tags; then
5+
echo "This commit has already been released."
6+
exit 1
7+
fi

0 commit comments

Comments
 (0)