Skip to content

Commit

Permalink
Test before publish (#1031)
Browse files Browse the repository at this point in the history
Run lint and tests before publish to avoid publishing obviously bad packages.
  • Loading branch information
Will Scullin authored Feb 24, 2023
1 parent 3fb0d4d commit be51621
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
17 changes: 16 additions & 1 deletion cloudbuild/deploy/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,36 @@ steps:
volumes:
- name: "ssh"
path: /root/.ssh
- id: nix-quiet-install
name: gcr.io/cloud-builders/docker
args:
- pull
- "-q"
- nixos/nix
- id: proxy-install
name: "nixos/nix"
entrypoint: sh
args:
- -c
- "wget -q -O /workspace/cloud_sql_proxy https://dl.google.com/cloudsql/cloud_sql_proxy.linux.386 && chmod +x /workspace/cloud_sql_proxy"
waitFor: ["nix-quiet-install"]
- id: deploy-npm
name: "nixos/nix"
entrypoint: sh
args:
- -c
- "./cloudbuild/deploy/$TRIGGER_NAME.sh"
- "(/workspace/cloud_sql_proxy -enable_iam_login -instances=malloy-303216:us-central1:pg-test=tcp:5432 -log_debug_stdout > /dev/null & sleep 2) && (./cloudbuild/deploy/$TRIGGER_NAME.sh)"
timeout: "1800s"
secretEnv: ["NPM_TOKEN", "GITHUB_SSH_KEY"]
env:
- "BRANCH_NAME=$BRANCH_NAME"
volumes:
- name: "ssh"
path: /root/.ssh
waitFor: ["git-ssh-key", "proxy-install"]
options:
logging: CLOUD_LOGGING_ONLY
machineType: "E2_HIGHCPU_8"
timeout: "1800s"
availableSecrets:
secretManager:
Expand Down
5 changes: 4 additions & 1 deletion cloudbuild/deploy/malloy-npm-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ export PACKAGES="packages/malloy packages/malloy-db-bigquery packages/malloy-db-

nix-shell --pure --keep NPM_TOKEN --keep PACKAGES --command "$(cat <<NIXCMD
set -euxo pipefail
export PGHOST=127.0.0.1
export PGDATABASE=postgres
export PGUSER=private-cloudbuild@malloy-303216.iam
cd /workspace
git branch -m main
npm --no-audit --no-fund ci --loglevel error
npm run build
npm run lint && npm run build && npm run build-duckdb-db && npm run test-silent
echo Publishing \$PACKAGES
PRERELEASE=\$(date +%y%m%d%H%M%S)
VERSION=\$(jq -r .version ./lerna.json)-dev\$PRERELEASE
Expand Down
5 changes: 4 additions & 1 deletion cloudbuild/deploy/malloy-npm-release-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export PACKAGES="packages/malloy packages/malloy-db-bigquery packages/malloy-db-

nix-shell --pure --keep NPM_TOKEN --keep PACKAGES --keep BRANCH_NAME --command "$(cat <<NIXCMD
set -euxo pipefail
export PGHOST=127.0.0.1
export PGDATABASE=postgres
export PGUSER=private-cloudbuild@malloy-303216.iam
cd /workspace
# Change to actual branch
git branch \$BRANCH_NAME
Expand All @@ -15,7 +18,7 @@ nix-shell --pure --keep NPM_TOKEN --keep PACKAGES --keep BRANCH_NAME --command "
git config --global user.name "Malloy CI Bot"
# Build
npm --no-audit --no-fund ci --loglevel error
npm run build
npm run lint && npm run build && npm run build-duckdb-db && npm run test-silent
# Publish
echo Publishing \$PACKAGES
VERSION=\$(jq -r .version ./lerna.json)
Expand Down

0 comments on commit be51621

Please sign in to comment.