change: use env for setting timezone in tests #22
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
name: Test | |
on: | |
## This workflow runs on every push to main (including merges) | |
push: | |
branches: [main] | |
## This workflow also runs for every opened PR or push to PR branch | |
pull_request: | |
jobs: | |
## First job that runs is linting. This ensures the syntax is valid in the | |
## first place. Feel free to reduce to `pnpm lint` if your ruleset is set up | |
## to where warnings are only stylistic preferences and not vital to ensure | |
## code validity. | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install pnpm v9 | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Install Node.js v22 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Lint | |
run: pnpm lint:strict | |
## This job runs after lint and runs prettier in check mode. | |
## Feel free to remove this if you're not strict with codestyle | |
format: | |
needs: lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install pnpm v9 | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Install Node.js v22 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Check Formatting | |
run: pnpm format:check | |
## This job runs after lint and runs TypeScript typechecks | |
types: | |
needs: lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install pnpm v9 | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Install Node.js v22 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Typecheck | |
run: pnpm typecheck | |
test: | |
needs: types | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# it is recommended to test at least previous LTS, LTS and Latest node | |
node-version: [20.x, 22.x, 23.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install pnpm v9 | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: pnpm | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Run Tests | |
run: pnpm test | |
env: | |
TZ: Europe/Berlin | |
- name: Rerun date-related tests with different TZ | |
run: pnpm tsx tests/formatTime.test.ts | |
env: | |
TZ: America/Los_Angeles |