From 8a8ff008f79d58a43d6d5c813a926a23b9ebd6b4 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Tue, 13 Aug 2024 13:01:07 -0700 Subject: [PATCH 1/3] Update docs/resource-collection Add reminder to also update revision number in `env/testing/config.json` --- docs/resource-collection.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/resource-collection.rst b/docs/resource-collection.rst index b053a31b1..af5f5889c 100644 --- a/docs/resource-collection.rst +++ b/docs/resource-collection.rst @@ -22,7 +22,8 @@ The nextstrain.org testing & production configs currently set this to ``s3://nextstrain-inventories/resources/v.json.gz``. If you make any updates that changes the structure or the contents of the resource -index JSON, then bump the ```` within the configs (``env/production/config.json``) +index JSON, then bump the ```` within the configs +(``env/testing/config.json`` and ``env/production/config.json``) so that any uploads to S3 does not disrupt the production server. These updates include changes to: From 255b868b2ff52ccf7858bc68f9bb74679e1d5471 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Tue, 13 Aug 2024 13:08:16 -0700 Subject: [PATCH 2/3] Always use production config.json in index-resources GH Action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensures that the index-resource workflow always uses the production config as our Heroku apps default to NODE_ENV=production.¹ ¹ --- .github/workflows/index-resources.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/index-resources.yml b/.github/workflows/index-resources.yml index 557354099..049ef16aa 100644 --- a/.github/workflows/index-resources.yml +++ b/.github/workflows/index-resources.yml @@ -44,6 +44,8 @@ jobs: env: HEROKU_TOKEN: ${{ secrets.HEROKU_TOKEN_READ_PROTECTED }} IS_WORKFLOW_CALL: ${{ inputs.is-workflow-call || false }} + # Ensure that we are using the production configs to match Heroku apps + CONFIG_FILE: ./env/production/config.json run: | # Assign to variable before output to ensure error exit code propagates to GH Action job ref_matrix=$(./scripts/get-resource-index-ref-matrix) From 9d45dd059d4712d997c9a57229294999ae023565 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Tue, 13 Aug 2024 16:28:22 -0700 Subject: [PATCH 3/3] CI: Check for matching RESOURCE_INDEX Based on feedback from @jameshadfield Ensure that the testing and production configs have matching RESOURCE_INDEX so that we don't accidentally upload an expected resource index version. --- .github/workflows/ci.yml | 1 + scripts/check-resource-index-match.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 scripts/check-resource-index-match.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 765b59a62..31be96150 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,7 @@ jobs: - run: npm ci - run: npm run lint:server - run: npm run lint:static-site + - run: node ./scripts/check-resource-index-match.js # Build into Heroku slug so we can deploy the same build that we test. build: diff --git a/scripts/check-resource-index-match.js b/scripts/check-resource-index-match.js new file mode 100644 index 000000000..c79b8d2b0 --- /dev/null +++ b/scripts/check-resource-index-match.js @@ -0,0 +1,16 @@ +import { readFileSync } from "fs"; + +const PRODUCTION_CONFIG = "env/production/config.json"; +const TESTING_CONFIG = "env/testing/config.json"; +const RESOURCE_INDEX = "RESOURCE_INDEX"; + +const production_index = JSON.parse(readFileSync(PRODUCTION_CONFIG, 'utf8'))[RESOURCE_INDEX] +const testing_index = JSON.parse(readFileSync(TESTING_CONFIG, 'utf8'))[RESOURCE_INDEX] + +if (production_index !== testing_index) { + console.error(`ERROR: Please make sure ${PRODUCTION_CONFIG} and ${TESTING_CONFIG} have the same ${RESOURCE_INDEX}!"`) + process.exit(1); +} else { + console.log(`Confirmed ${PRODUCTION_CONFIG} and ${TESTING_CONFIG} have the same ${RESOURCE_INDEX}`); + process.exit(0); +}