Skip to content

Commit

Permalink
TEST resolving a specific Node version from semver specifiers
Browse files Browse the repository at this point in the history
TEST output step summary
  • Loading branch information
p2edwards committed Aug 23, 2024
1 parent 56e5f47 commit ee0d9fd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 45 deletions.
100 changes: 56 additions & 44 deletions .github/workflows/npm-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,69 @@ jobs:
node-version:
- '16.15.0' # prior pinned Node version supported by kpi
- '20.17.0' # version pinned for kpi release
- '20' # latest available v20
- '22' # latest available v22
fail-fast: false # Let each job finish

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
check-latest: true # download newer semver match if available
cache: 'npm'

# Set up Chrome, for the unit tests
- uses: browser-actions/setup-chrome@latest
- run: chrome --version
- name: Identify resolved node version
id: resolved-node-version
run: echo "NODE_VERSION=$(node --version)" >> "$GITHUB_OUTPUT"
- name: Add "Node v${{ steps.resolved-node-version.outputs.NODE_VERSION }}" to summary
run: echo "${{ matrix.node-version }} → **${{ steps.resolved-node-version.outputs.NODE_VERSION }}**" >> "$GITHUB_STEP_SUMMARY"

# Cache node_modules, keyed on os, node version, package-lock, and patches
- uses: actions/cache@v4
name: Check for cached node_modules
id: cache-nodemodules
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-node-v${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json', 'patches/**/*.patch') }}

# Cache hit: node_modules is copied from a previous run. Run copy-fonts
- if: steps.cache-nodemodules.outputs.cache-hit == 'true'
name: Run copy-fonts (if using cached node_modules)
run: npm run copy-fonts

# Cache miss: Run npm install, which does copy-fonts as post-install step
- if: steps.cache-nodemodules.outputs.cache-hit != 'true'
name: Install JavaScript dependencies (npm install)
run: npm install

# Build the app!
- name: Build Prod
run: SKIP_TS_CHECK=true npm run build

# Run TypeScript Checks and ESLint
- name: Check TypeScript # Separated for visibility
run: npm run check-types
- name: Check ESLint, errors only
run: npm run lint -- --quiet

# Unit Tests
- name: Build Tests
run: npx webpack --config webpack/test.config.js

- name: Run Tests, with mocha-chrome
run: npx mocha-chrome test/tests.html --chrome-launcher.connectionPollInterval=5000
# This step takes less than 1 minute if it succeeds, but will hang for
# 6 hours if it fails with 'No inspectable targets'
# Timeout early to make it easier to manually re-run jobs.
# Tracking issue: https://github.com/kobotoolbox/kpi/issues/4337
timeout-minutes: 1

# COMMENT FOR INITIAL TEST

# # Set up Chrome, for the unit tests
# - uses: browser-actions/setup-chrome@latest
# - run: chrome --version

# # Cache node_modules, keyed on os, node version, package-lock, and patches
# - uses: actions/cache@v4
# name: Check for cached node_modules
# id: cache-nodemodules
# env:
# cache-name: cache-node-modules
# with:
# path: node_modules
# key: ${{ runner.os }}-build-${{ env.cache-name }}-node-v${{ steps.resolved-node-version.outputs.NODE_VERSION }}-${{ hashFiles('**/package-lock.json', 'patches/**/*.patch') }}

# # Cache hit: node_modules is copied from a previous run. Run copy-fonts
# - if: steps.cache-nodemodules.outputs.cache-hit == 'true'
# name: Run copy-fonts (if using cached node_modules)
# run: npm run copy-fonts

# # Cache miss: Run npm install, which does copy-fonts as post-install step
# - if: steps.cache-nodemodules.outputs.cache-hit != 'true'
# name: Install JavaScript dependencies (npm install)
# run: npm install

# # Build the app!
# - name: Build Prod
# run: SKIP_TS_CHECK=true npm run build

# # Run TypeScript Checks and ESLint
# - name: Check TypeScript # Separated for visibility
# run: npm run check-types
# - name: Check ESLint, errors only
# run: npm run lint -- --quiet

# # Unit Tests
# - name: Build Tests
# run: npx webpack --config webpack/test.config.js

# - name: Run Tests, with mocha-chrome
# run: npx mocha-chrome test/tests.html --chrome-launcher.connectionPollInterval=5000
# # This step takes less than 1 minute if it succeeds, but will hang for
# # 6 hours if it fails with 'No inspectable targets'
# # Timeout early to make it easier to manually re-run jobs.
# # Tracking issue: https://github.com/kobotoolbox/kpi/issues/4337
# timeout-minutes: 1
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ee0d9fd

Please sign in to comment.