build(deps): bump the migrator-prod group across 1 directory with 2 updates #1248
Workflow file for this run
This file contains hidden or 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
| name: Run all PR checks | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| changes: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| outputs: | |
| server: ${{ steps.filter.outputs.server }} | |
| client: ${{ steps.filter.outputs.client }} | |
| db: ${{ steps.filter.outputs.db }} | |
| migrator: ${{ steps.filter.outputs.migrator }} | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| persist-credentials: false | |
| - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1 | |
| id: filter | |
| with: | |
| filters: | | |
| server: | |
| - 'server/**' | |
| client: | |
| - 'client/**' | |
| db: | |
| - 'db/**' | |
| migrator: | |
| - 'migrator/**' | |
| check_generated_graphql: | |
| timeout-minutes: 4 | |
| needs: [changes] | |
| if: needs.changes.outputs.server == 'true' || needs.changes.outputs.client == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| persist-credentials: false | |
| - name: Check generated GraphQL is up to date | |
| run: docker compose run --rm --quiet-pull codegen-check | |
| check_migration_order: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| # this is needed to fetch the main branch | |
| ref: ${{ github.base_ref || 'main' }} | |
| fetch-depth: 1 | |
| sparse-checkout: 'db/src/scripts' | |
| persist-credentials: false | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| # this is needed to fetch the main branch | |
| fetch-depth: 1 | |
| sparse-checkout: 'db/src/scripts' | |
| persist-credentials: false | |
| - name: Check changed migration files | |
| id: check-changed-migration-files | |
| run: | | |
| # Helpers to print in different colors | |
| # Found here: https://gist.github.com/stevewithington/b1b620b5bc9252e2c32e2cad35efbf83#bash-ansi-variables | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| # Extract the datestamp from the filename by pulling the path's | |
| # basename, reversing it, delimiting the string by the "." character, | |
| # chop off the first 3 tokens, and reverse it again to be left with | |
| # the datestamp. | |
| # | |
| # NB: The filename will look something like: | |
| # 2022.12.22T03.39.16.example_migration.(cjs|sql|cql) | |
| datestamp() { | |
| echo $(basename $1 | rev | cut -d . -f3- | rev) | |
| } | |
| validate_migration() { | |
| local file=$1 | |
| local most_recent_datestamp=$2 | |
| local file_datestamp=$(datestamp "${file}") | |
| if [[ "$file_datestamp" > "$most_recent_datestamp" ]]; then | |
| echo -e "${GREEN}Valid migration ${file}." | |
| else | |
| echo -e "${RED}Error: Invalid migration: new migration's datestamp ($file_datestamp) is earlier than the most recent existing migration's datestamp ($most_recent_datestamp)" | |
| exit 1 | |
| fi | |
| } | |
| SCRIPTS_DIR="db/src/scripts/" | |
| # Checkout main so that we're correctly identifying the existing migrations | |
| # in the loop below. | |
| git checkout "$BASE_REF" | |
| # Loop through each sub-directory under the scripts directory | |
| for subdir in ${SCRIPTS_DIR}*/ ; do | |
| existing_migrations=("$subdir"*.{sql,cjs,cql}) | |
| IFS=$'\n' sorted_existing_migrations=($(sort <<<"${existing_migrations[*]}")) | |
| most_recent_migration_datestamp=$(datestamp ${sorted_existing_migrations[-1]}) | |
| readarray -t CHANGED_FILES < <(git diff --name-only "$GITHUB_SHA" "$BASE_REF") | |
| # Identify and validate changed migration files in the current sub-directory | |
| printf "%s\n" "${existing_migrations[@]}" | |
| printf "%s\n" "${sorted_existing_migrations[@]}" | |
| if [ ${#CHANGED_FILES[@]} -ne 0 ]; then | |
| for file in "${CHANGED_FILES[@]}" | |
| do | |
| if [[ "${file}" == ${subdir}* ]]; then | |
| validate_migration "${file}" "${most_recent_migration_datestamp}" | |
| else | |
| echo -e "Skipping ${file} because it is not in the ${subdir} directory." | |
| fi | |
| done | |
| fi | |
| done | |
| exit 0 | |
| env: | |
| BASE_REF: ${{ github.base_ref || 'main' }} | |
| # jobs have to be defined in the root workflow file in order to be marked as | |
| # 'Required Checks' in GitHub CI | |
| check_api_server: | |
| needs: changes | |
| if: needs.changes.outputs.server == 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: read | |
| actions: read | |
| checks: write # for dorny/test-reporter to create a check run | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| persist-credentials: false | |
| - name: Lint | |
| run: docker compose run --rm --quiet-pull backend npm run lint | |
| - name: Build server | |
| run: docker compose run --rm --quiet-pull backend npm run build | |
| - name: Migrate CI DBs and Test | |
| run: | | |
| docker compose run --rm --quiet-pull test | |
| echo "ATTENTION: If this step fails, look in the next step for the migration logs." | |
| - # Only output the migration logs if the prior step failed, as they | |
| # could be helpful for debugging in that case; otherwise, they're just | |
| # noise that's costing us money in Datadog. | |
| if: failure() | |
| name: Get Migrations Logs | |
| run: docker compose logs migrations | |
| - name: Test Report | |
| if: always() # run this step even if previous step failed | |
| uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 | |
| continue-on-error: true | |
| with: | |
| name: JEST Tests # Name of the check run which will be created | |
| path: server/reports/jest-*.xml # Path to test results | |
| reporter: jest-junit # Format of test results | |
| run_frontend_checks_if_changed: | |
| needs: changes | |
| if: needs.changes.outputs.client == 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 25 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| persist-credentials: false | |
| - name: Lint client | |
| run: docker compose run --rm --quiet-pull client npm run lint | |
| - name: Build client | |
| run: docker compose run --rm --quiet-pull client npm run build | |
| # db and migrator have no ESLint setup, so CI only typechecks them. | |
| typecheck_db: | |
| needs: changes | |
| if: needs.changes.outputs.db == 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'npm' | |
| cache-dependency-path: 'db/package-lock.json' | |
| - name: Typecheck db | |
| run: | | |
| cd db | |
| npm ci | |
| npm run typecheck | |
| typecheck_migrator: | |
| needs: changes | |
| if: needs.changes.outputs.migrator == 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| persist-credentials: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'npm' | |
| cache-dependency-path: 'migrator/package-lock.json' | |
| - name: Typecheck migrator | |
| run: | | |
| cd migrator | |
| npm ci | |
| npm run typecheck |