From e260db8edc884589e79eb0851b03740e26acfbff Mon Sep 17 00:00:00 2001 From: Nicholas Chiang Date: Tue, 21 Mar 2023 00:33:04 -0600 Subject: [PATCH] build: bump node version to latest lts 18 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]: https://github.com/bahmutov/npm-install/issues/146 --- .github/workflows/deploy.yml | 44 +++++++++++++++++++---------------- .github/workflows/release.yml | 14 ++++++----- Dockerfile | 2 +- package.json | 2 +- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 95979828..8462d564 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,7 +15,7 @@ jobs: name: ESLint runs-on: ubuntu-latest steps: - - name: Cancel Previous Runs + - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.11.0 - name: Checkout repo @@ -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 @@ -42,7 +43,7 @@ jobs: name: TypeScript runs-on: ubuntu-latest steps: - - name: Cancel Previous Runs + - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.11.0 - name: Checkout repo @@ -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 @@ -63,7 +65,7 @@ jobs: name: Vitest runs-on: ubuntu-latest steps: - - name: Cancel Previous Runs + - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.11.0 - name: Checkout repo @@ -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 @@ -84,7 +87,7 @@ jobs: name: Cypress runs-on: ubuntu-latest steps: - - name: Cancel Previous Runs + - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.11.0 - name: Checkout repo @@ -96,10 +99,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: Docker compose # the sleep is just there to give time for postgres to get started @@ -107,7 +111,7 @@ jobs: env: DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/postgres' - - name: Setup Database + - name: Setup database run: yarn prisma migrate reset --force - name: Build @@ -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/cancel-workflow-action@0.11.0 - name: Checkout repo @@ -143,11 +147,11 @@ 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 @@ -155,7 +159,7 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- - - name: Fly Registry Auth + - name: Fly registry auth uses: docker/login-action@v2 with: registry: registry.fly.io @@ -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/cancel-workflow-action@0.11.0 - name: Checkout repo @@ -204,7 +208,7 @@ jobs: file: 'fly.toml' field: 'app' - - name: Deploy Staging + - name: Deploy staging if: ${{ github.ref == 'refs/heads/main' }} uses: superfly/flyctl-actions@1.3 with: @@ -212,7 +216,7 @@ jobs: env: FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} - - name: Deploy Production + - name: Deploy production if: ${{ github.ref == 'refs/heads/prod' }} uses: superfly/flyctl-actions@1.3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a23b11b..6f80f44d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 && \ @@ -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 diff --git a/Dockerfile b/Dockerfile index 81bd98d4..0b8ca9b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/package.json b/package.json index c0eb5a9e..b7f9450e 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "vitest": "^0.28.3" }, "engines": { - "node": ">=14" + "node": ">=18" }, "prisma": { "seed": "ts-node --require tsconfig-paths/register prisma/seed.ts"