Skip to content

Commit

Permalink
ci: migrate to pnpm (#41)
Browse files Browse the repository at this point in the history
* ci: migrate to pnpm
* fix: type for mdxSource
* fix: add packageManager to fix vercel build
* ci: pin pnpm version
* docs: changeset
  • Loading branch information
cseas authored Dec 23, 2024
1 parent 7b03ee8 commit 4d9d4e6
Show file tree
Hide file tree
Showing 13 changed files with 7,701 additions and 21,030 deletions.
24 changes: 24 additions & 0 deletions .changeset/funny-actors-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
"blog": patch
---

ci: migrate to pnpm

## Summary by CodeRabbit

- **New Features**

- Introduced a new GitHub Actions workflow for validating source code during pull requests.
- Added a script for TypeScript type checking in the project.

- **Improvements**

- Updated workflows to streamline dependency installation and caching processes.
- Upgraded action versions for improved performance and compatibility.

- **Bug Fixes**

- Removed outdated entries from `.gitignore` and `README.md`, allowing for better tracking and clarity.

- **Chores**
- Enhanced configuration in `package.json` to enforce specific engine requirements for package management.
26 changes: 26 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Install npm packages
description: Installs npm packages and manages its cache

env:
NODE_VERSION: 22.9.0
PNPM_VERSION: 9.15.1

runs:
using: composite
steps:
# https://github.com/pnpm/action-setup?tab=readme-ov-file#use-cache-to-reduce-installation-time
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
run_install: false

- name: Setup Node.js v${{ env.NODE_VERSION }} with pnpm cache
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"

- name: Install Dependencies
shell: bash
run: pnpm install --frozen-lockfile
11 changes: 3 additions & 8 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install Dependencies
run: npm install
- name: Setup Cache & Install Dependencies
uses: ./.github/actions/install-dependencies

- name: Create Release Pull Request
uses: changesets/action@v1
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/checklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
- name: Changeset
if: |
github.event.workflow_run.conclusion == 'success' &&
github.event.pull_request.draft == false &&
!(contains(github.event.pull_request.labels.*.name, 'changeset-not-applicable') ||
contains(github.event.pull_request.labels.*.name, 'changeset-added'))
Expand Down
25 changes: 11 additions & 14 deletions .github/workflows/nextjs_bundle_analysis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

name: 'Next.js Bundle Analysis'
name: "Next.js Bundle Analysis"

on:
pull_request:
Expand All @@ -24,24 +24,21 @@ jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install dependencies
uses: bahmutov/npm-install@v1
node-version: 22

# If pnpm is used, you need to switch the previous step with the following one. pnpm does not create a package-lock.json
# so the step above will fail to pull dependencies
# - uses: pnpm/action-setup@v2
# name: Install pnpm
# id: pnpm-install
# with:
# version: 7
# run_install: true
- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 9.15.1
run_install: true

- name: Restore next build
uses: actions/cache@v3
Expand Down Expand Up @@ -110,7 +107,7 @@ jobs:
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: '<!-- __NEXTJS_BUNDLE -->'
body-includes: "<!-- __NEXTJS_BUNDLE -->"

- name: Create Comment
uses: peter-evans/create-or-update-comment@v2
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Validate

on:
pull_request:
types:
- opened
- reopened
- synchronize

env:
NODE_VERSION: 22.9.0

jobs:
validate:
name: Validate Source Code
if: |
!((github.actor == 'github-actions[bot]' || contains(github.event.pull_request.title, 'ci: update version & changelog')) && github.head_ref == 'changeset-release/main')
runs-on: ubuntu-latest
steps:
- name: Checkout Codebase
uses: actions/checkout@v4

- name: Setup Cache & Install Dependencies
uses: ./.github/actions/install-dependencies

- name: Print timezone for timezone based tests
run: date

- name: Lint Source Code
run: pnpm run lint

- name: Run TypeScript Checks
run: pnpm run typecheck

- name: Build
run: pnpm run build

# test:
# name: Run Tests
# if: |
# !((github.actor == 'rzpcibot' || contains(github.event.pull_request.title, 'build(onboarding-sdk): update version')) && github.head_ref == 'changeset-release/master')
# runs-on: self-hosted
# steps:
# - name: Checkout Codebase
# uses: actions/checkout@v4
# - name: Use Node v${{ env.NODE_VERSION }}
# uses: actions/setup-node@v4
# with:
# node-version: ${{ env.NODE_VERSION }}
# - name: Setup Cache & Install Dependencies
# uses: ./.github/actions/install-dependencies
# - name: Run Unit Tests
# run: pnpm test:coverage
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

Expand All @@ -33,7 +32,8 @@ yarn-error.log*
# vercel
.vercel

drafts/

# Editor
.vscode/
.vscode/

# ci
tsconfig.tsbuildinfo
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,4 @@ Code for my personal blog, hosted at [blog.absingh.com][1].
- [ ] use Inter variable font from @next/font
- [ ] dig command, post: powershell-ip

### Runtime software versions

| Name | Version |
| ---- | ------- |
| node | v22.9.0 |
| npm | 10.8.3 |

[1]: https://blog.absingh.com/
Loading

0 comments on commit 4d9d4e6

Please sign in to comment.