Skip to content

Commit

Permalink
Merge pull request #983 from nextstrain/production-indexer
Browse files Browse the repository at this point in the history
Always use production config.json in index-resources GH Action
  • Loading branch information
joverlee521 authored Aug 14, 2024
2 parents bc3158e + 9d45dd0 commit 1a01f08
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/index-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion docs/resource-collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ The nextstrain.org testing & production configs currently set this to
``s3://nextstrain-inventories/resources/v<revision_number>.json.gz``.

If you make any updates that changes the structure or the contents of the resource
index JSON, then bump the ``<revision_number>`` within the configs (``env/production/config.json``)
index JSON, then bump the ``<revision_number>`` 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:
Expand Down
16 changes: 16 additions & 0 deletions scripts/check-resource-index-match.js
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 1a01f08

Please sign in to comment.