Skip to content

Commit

Permalink
build: bump node version to latest lts 18
Browse files Browse the repository at this point in the history
This commit bumps the Node.js engine specified in `package.json` to be
the latest LTS (18) and updates the Dockerfile and actions accordingly.

This change should also speed up CI as dependencies are now cached
properly by the setup node action instead of the previously buggy [[1]]
install dependencies action.

[1]: bahmutov/npm-install#146
  • Loading branch information
nicholaschiang committed Mar 21, 2023
1 parent 5e3e111 commit e260db8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
44 changes: 24 additions & 20 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: ESLint
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
- name: Cancel previous runs
uses: styfle/[email protected]

- name: Checkout repo
Expand All @@ -24,10 +24,11 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version-file: package.json
cache: yarn

- name: Download deps
uses: bahmutov/npm-install@v1
run: yarn install --immutable

# Linting fails in CI because `~/styles/tailwind.css` does not exist and
# thus my `import/order` rule errors (because it doesn't mark that as a
Expand All @@ -42,7 +43,7 @@ jobs:
name: TypeScript
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
- name: Cancel previous runs
uses: styfle/[email protected]

- name: Checkout repo
Expand All @@ -51,10 +52,11 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version-file: package.json
cache: yarn

- name: Download deps
uses: bahmutov/npm-install@v1
run: yarn install --immutable

- name: Type check
run: yarn typecheck
Expand All @@ -63,7 +65,7 @@ jobs:
name: Vitest
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
- name: Cancel previous runs
uses: styfle/[email protected]

- name: Checkout repo
Expand All @@ -72,10 +74,11 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version-file: package.json
cache: yarn

- name: Download deps
uses: bahmutov/npm-install@v1
run: yarn install --immutable

- name: Run vitest
run: yarn test -- --coverage
Expand All @@ -84,7 +87,7 @@ jobs:
name: Cypress
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
- name: Cancel previous runs
uses: styfle/[email protected]

- name: Checkout repo
Expand All @@ -96,18 +99,19 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version-file: package.json
cache: yarn

- name: Download deps
uses: bahmutov/npm-install@v1
run: yarn install --immutable

- name: Docker compose
# the sleep is just there to give time for postgres to get started
run: docker-compose up -d && sleep 3
env:
DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/postgres'

- name: Setup Database
- name: Setup database
run: yarn prisma migrate reset --force

- name: Build
Expand All @@ -130,7 +134,7 @@ jobs:
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prod') && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
- name: Cancel previous runs
uses: styfle/[email protected]

- name: Checkout repo
Expand All @@ -143,19 +147,19 @@ jobs:
file: 'fly.toml'
field: 'app'

- name: Set up Docker Buildx
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2

# Setup cache
- name: Cache Docker layers
- name: Cache docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Fly Registry Auth
- name: Fly registry auth
uses: docker/login-action@v2
with:
registry: registry.fly.io
Expand Down Expand Up @@ -191,7 +195,7 @@ jobs:
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prod') && github.event_name == 'push' }}

steps:
- name: Cancel Previous Runs
- name: Cancel previous runs
uses: styfle/[email protected]

- name: Checkout repo
Expand All @@ -204,15 +208,15 @@ jobs:
file: 'fly.toml'
field: 'app'

- name: Deploy Staging
- name: Deploy staging
if: ${{ github.ref == 'refs/heads/main' }}
uses: superfly/[email protected]
with:
args: 'deploy --app ${{ steps.app_name.outputs.value }}-staging --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}'
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

- name: Deploy Production
- name: Deploy production
if: ${{ github.ref == 'refs/heads/prod' }}
uses: superfly/[email protected]
with:
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version-file: package.json
cache: yarn

- name: Download deps
run: yarn install --immutable

- name: Checkout branch
run: git checkout $GITHUB_HEAD_REF

- name: Download deps
uses: bahmutov/npm-install@v1

- name: Release
run: |
unset GITHUB_ACTIONS && \
Expand Down Expand Up @@ -61,10 +62,11 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version-file: package.json
cache: yarn

- name: Download deps
uses: bahmutov/npm-install@v1
run: yarn install --immutable

- name: Release
run: yarn semantic-release --ci
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# base node image
FROM node:16-bullseye-slim as base
FROM node:18-bullseye-slim as base

# set for base and all layer that inherit from it
ENV NODE_ENV production
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"vitest": "^0.28.3"
},
"engines": {
"node": ">=14"
"node": ">=18"
},
"prisma": {
"seed": "ts-node --require tsconfig-paths/register prisma/seed.ts"
Expand Down

0 comments on commit e260db8

Please sign in to comment.