-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: run CI on GitHub workflow, not Cloud Build
- Loading branch information
Showing
57 changed files
with
631 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,49 +22,69 @@ jobs: | |
steps: | ||
- name: 🛎️ Check out repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: ⚙️ Set up Node.js ${{ matrix.node }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
# TODO: fix trigger for Cloud Build. DO NOT build/test here. | ||
|
||
- name: ⚙️ Install dependencies | ||
run: npm ci | ||
|
||
- name: 🔧 Build packages | ||
run: npm run build | ||
|
||
- name: 🔍 Test library @jackdbd/checks | ||
run: npm run test:ci -w packages/checks | ||
|
||
- name: 🔍 Test library @jackdbd/hapi-healthcheck-plugin | ||
run: npm run test:ci -w packages/hapi-healthcheck-plugin | ||
|
||
- name: 🔍 Test library @jackdbd/hapi-ip-whitelist-plugin | ||
run: npm run test:ci -w packages/hapi-ip-whitelist-plugin | ||
|
||
- name: 🔍 Test library @jackdbd/plausible-client | ||
env: | ||
PLAUSIBLE: ${{ secrets.PLAUSIBLE }} | ||
run: npm run test:ci -w packages/plausible-client | ||
|
||
# - name: 🔍 Test library @jackdbd/secret-manager-utils | ||
# env: | ||
# SA_SECRET_MANAGER_ADMIN_TEST: ${{ secrets.SA_SECRET_MANAGER_ADMIN_TEST }} | ||
# run: npm run test:ci -w packages/secret-manager-utils | ||
|
||
- name: 🔍 Test library @jackdbd/telegram-text-messages | ||
run: npm run test:ci -w packages/telegram-text-messages | ||
|
||
- name: 🔍 Test library @jackdbd/utils | ||
run: npm run test:ci -w packages/utils | ||
|
||
- name: ⬆️ Upload test coverage to Codecov | ||
# https://github.com/marketplace/actions/codecov | ||
uses: codecov/[email protected] | ||
with: | ||
fail_ci_if_error: true | ||
verbose: true | ||
|
||
|
||
# - name: ⬆️ Upload test coverage to Codecov | ||
# # https://github.com/marketplace/actions/codecov | ||
# uses: codecov/[email protected] | ||
# with: | ||
# fail_ci_if_error: true | ||
# verbose: true | ||
# TODO: fix trigger for Cloud Build. DO build on Cloud Build. | ||
- name: 🛂 Authenticate to Google Cloud | ||
# https://github.com/google-github-actions/auth | ||
uses: google-github-actions/auth@v0 | ||
with: | ||
credentials_json: ${{ secrets.SA_GITHUB_WORKFLOWS }} | ||
- name: ⚙️ Set up gcloud | ||
# https://github.com/marketplace/actions/set-up-gcloud-cloud-sdk-environment | ||
uses: google-github-actions/setup-gcloud@v0 | ||
- name: 🔑 Refresh access token for Artifact Registry | ||
run: npx google-artifactregistry-auth --repo-config ./config/repo-config-npmrc-artifact-registry --verbose | ||
- run: gcloud info | ||
- name: ⚡ Trigger build on Cloud Build | ||
# reminder for YAML single-line and multi-line strings | ||
# https://stackoverflow.com/a/3790497/3036129 | ||
run: > | ||
gcloud builds submit | ||
--config cloudbuild.yaml | ||
--project ${{ secrets.GCP_PROJECT_ID }} | ||
--async | ||
--substitutions _NODE_VERSION=${{ matrix.node }} | ||
--timeout 9m59s | ||
# - name: 🛂 Authenticate to Google Cloud | ||
# # https://github.com/google-github-actions/auth | ||
# uses: google-github-actions/auth@v0 | ||
# with: | ||
# credentials_json: ${{ secrets.SA_GITHUB_WORKFLOWS }} | ||
# - name: ⚙️ Set up gcloud | ||
# # https://github.com/marketplace/actions/set-up-gcloud-cloud-sdk-environment | ||
# uses: google-github-actions/setup-gcloud@v0 | ||
# - name: 🔑 Refresh access token for Artifact Registry | ||
# run: npx google-artifactregistry-auth --repo-config ./config/repo-config-npmrc-artifact-registry --verbose | ||
# - run: gcloud info | ||
# - name: ⚡ Trigger build on Cloud Build | ||
# # reminder for YAML single-line and multi-line strings | ||
# # https://stackoverflow.com/a/3790497/3036129 | ||
# run: > | ||
# gcloud builds submit | ||
# --config cloudbuild.yaml | ||
# --project ${{ secrets.GCP_PROJECT_ID }} | ||
# --async | ||
# --substitutions _NODE_VERSION=${{ matrix.node }} | ||
# --timeout 9m59s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,6 @@ jobs: | |
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | ||
steps: | ||
# - name: Dump github.event | ||
# run: echo '${{ toJSON(github.event) }}' | ||
- name: Dump TELEGRAM to JSON | ||
run: echo '${{ toJSON(secrets.TELEGRAM) }}' | ||
- name: Dump TELEGRAM from JSON | ||
run: echo '${{ fromJSON(secrets.TELEGRAM) }}' | ||
- name: 💬 Notify Telegram of workflow run FAILURE | ||
# https://github.com/appleboy/telegram-action | ||
uses: appleboy/[email protected] | ||
|
@@ -30,11 +24,13 @@ jobs: | |
disable_web_page_preview: true | ||
# https://core.telegram.org/bots/api#formatting-options | ||
message: | | ||
<b>⚠️ GitHub workflow ${{ github.event.workflow_run.name }} in ${{ github.event.repository.name }} failed 💔</b> | ||
<b>⚠️ GitHub workflow failure 💔</b> | ||
Repository: <a href="${{ github.event.repository.html_url }}">${{ github.event.repository.full_name }}</a> | ||
Run ID: <a href="${{ github.event.workflow_run.html_url }}">${{ github.event.workflow_run.id }}</a> | ||
Workflow: <a href="${{ github.event.workflow_run.html_url }}">${{ github.event.workflow_run.name }}</a> | ||
Workflow Run ID: <a href="${{ github.event.workflow_run.html_url }}?check_suite_focus=true">${{ github.event.workflow_run.id }}</a> | ||
on-success: | ||
runs-on: ubuntu-latest | ||
|
@@ -50,8 +46,10 @@ jobs: | |
format: html | ||
disable_web_page_preview: true | ||
message: | | ||
<b>✅ GitHub workflow ${{ github.event.workflow_run.name }} in ${{ github.event.repository.name }} ran successfully 💖</b> | ||
<b>✅ GitHub workflow success 💖</b> | ||
Repository: <a href="${{ github.event.repository.html_url }}">${{ github.event.repository.full_name }}</a> | ||
Run ID: <a href="${{ github.event.workflow_run.html_url }}">${{ github.event.workflow_run.id }}</a> | ||
Workflow: <a href="${{ github.event.workflow_run.html_url }}">${{ github.event.workflow_run.name }}</a> | ||
Workflow Run ID: <a href="${{ github.event.workflow_run.html_url }}?check_suite_focus=true">${{ github.event.workflow_run.id }}</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Cloud Build conmfig files and triggers | ||
|
||
TODO: add brief explanation | ||
|
||
Artifact Registry Repository Administrator | ||
Cloud Build Service Account | ||
Cloud Build Service Agent | ||
Cloud Functions Developer | ||
<!-- Cloud Run Admin --> | ||
Secret Manager Secret Accessor | ||
Service Account User | ||
|
||
Cloud Build service account permissions | ||
https://console.cloud.google.com/cloud-build/settings/service-account?project=prj-kitchen-sink | ||
|
||
IAM section of the project | ||
https://console.cloud.google.com/iam-admin/iam?project=prj-kitchen-sink | ||
|
||
Cloud Build Service Account vs Cloud Build Service Agent? | ||
https://stackoverflow.com/questions/58752932/what-is-the-difference-between-the-cloud-build-service-account-and-service-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | ||
set -euxo pipefail | ||
|
||
### Uncomment this section to try out the script on my computer ################ | ||
# NPM_SCOPE=jackdbd | ||
# NPM_PACKAGE_NAME=checks | ||
# NPM_PACKAGE_VERSION=latest | ||
# DOWNLOAD_DIR=$(mktemp -d -t npm-pkg-XXXXXXXXXX) | ||
|
||
# echo "Download @${NPM_SCOPE}/${NPM_PACKAGE_NAME}@${NPM_PACKAGE_VERSION}" | ||
# npm pack "@${NPM_SCOPE}/${NPM_PACKAGE_NAME}@${NPM_PACKAGE_VERSION}" \ | ||
# --pack-destination="${DOWNLOAD_DIR}" | ||
################################################################################ | ||
|
||
cd "${DOWNLOAD_DIR}" | ||
|
||
tar_filename_with_extension=$(ls -C) | ||
# https://stackoverflow.com/questions/23431895/how-do-i-split-string-on-last-in-bash | ||
# https://cloud.google.com/build/docs/configuring-builds/use-bash-and-bindings-in-substitutions#bash_parameter_expansions | ||
version_with_extension="${tar_filename_with_extension##*-}" | ||
# echo "version_with_extension ${version_with_extension}" | ||
version="${version_with_extension%.*}" | ||
|
||
echo "Extract ${DOWNLOAD_DIR}/${NPM_SCOPE}-${NPM_PACKAGE_NAME}-${version}" | ||
tar -xvf "${NPM_SCOPE}-${NPM_PACKAGE_NAME}-${version_with_extension}" | ||
|
||
echo "which wget" | ||
echo which wget | ||
|
||
echo "which curl" | ||
echo which curl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | ||
set -euxo pipefail | ||
|
||
### Uncomment this section to try out the script on my computer ################ | ||
# NPM_SCOPE=jackdbd | ||
# NPM_PACKAGE_NAME=checks | ||
# NPM_PACKAGE_VERSION_FILE=latest-npm-package-version.txt | ||
# REPO_ID=npm-registry | ||
# REPO_LOCATION_ID=europe-west3 | ||
################################################################################ | ||
|
||
echo "Retrieve latest version of @${NPM_SCOPE}/${NPM_PACKAGE_NAME} from Artifact Registry repository \"${REPO_ID}\" (${REPO_LOCATION_ID})" | ||
|
||
latest_version=$(gcloud artifacts versions list \ | ||
--sort-by ~UPDATE_TIME \ | ||
--limit 1 \ | ||
--format 'value(format("{0}",name))' \ | ||
--location ${REPO_LOCATION_ID} \ | ||
--repository ${REPO_ID} \ | ||
--package "@${NPM_SCOPE}/${NPM_PACKAGE_NAME}") | ||
|
||
echo "write latest version of package @${NPM_SCOPE}/${NPM_PACKAGE_NAME} to ${NPM_PACKAGE_VERSION_FILE}" | ||
echo "${latest_version}" > ${NPM_PACKAGE_VERSION_FILE} | ||
cat ${NPM_PACKAGE_VERSION_FILE} |
Oops, something went wrong.