Skip to content

Commit

Permalink
ci: refactor workflows to streamline jobs and pnpm usage
Browse files Browse the repository at this point in the history
  • Loading branch information
DariuszPorowski committed Dec 28, 2024
1 parent ba41676 commit e41e87d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 121 deletions.
128 changes: 10 additions & 118 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,125 +13,17 @@ on:
push:
branches:
- main
workflow_dispatch:
inputs:
debug:
type: choice
description: Debug mode
required: false
options:
- 'true'
- 'false'

# Allow one concurrent
concurrency:
group: ${{ format('{0}-{1}-{2}-{3}-{4}', github.workflow, github.event_name, github.ref, github.base_ref, github.head_ref) }}
cancel-in-progress: true

env:
DEBUG: ${{ inputs.debug || secrets.ACTIONS_RUNNER_DEBUG || vars.ACTIONS_RUNNER_DEBUG || secrets.ACTIONS_STEP_DEBUG || vars.ACTIONS_STEP_DEBUG || false }}
permissions:
contents: read
issues: write
pull-requests: write
checks: write
actions: write
id-token: write

jobs:
build-test:
name: Build and Test
if: ${{ contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) || (github.event_name == 'pull_request' && !github.event.pull_request.draft) }}
permissions:
contents: read
issues: read
checks: write
pull-requests: write
actions: write
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
- name: 🩺 Debug
if: ${{ env.DEBUG == 'true' }}
uses: raven-actions/debug@v1
with:
vars-context: ${{ toJson(vars) }}
secrets-context: ${{ toJson(secrets) }}
needs-context: ${{ toJson(needs) }}
inputs-context: ${{ toJson(inputs) }}

- name: ⤵️ Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🔄️ Detect changes
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
app:
- 'src/**'
- 'tests/**'
- 'package.json'
- 'package-lock.json'
- '.node-version'
- 'jest.config.js'
- 'tsconfig.json'
- name: 🚧 Install pnpm
if: ${{ steps.changes.outputs.app == 'true' }}
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: 🚧 Setup Node
if: ${{ steps.changes.outputs.app == 'true' }}
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm

- name: 🔀 Install dependencies
if: ${{ steps.changes.outputs.app == 'true' }}
run: pnpm install --frozen-lockfile

- name: 🏗️ Build
if: ${{ steps.changes.outputs.app == 'true' }}
run: pnpm build:ci

- name: 🧪 Test
if: ${{ steps.changes.outputs.app == 'true' }}
run: pnpm test:ci:cov
continue-on-error: true

- name: 📤 Upload test results
if: ${{ steps.changes.outputs.app == 'true' && matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: test-results
path: 'reports/jest-*.xml'
if-no-files-found: warn

- name: 📤 Upload coverage results
if: ${{ steps.changes.outputs.app == 'true' && matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: coverage-results
path: coverage
if-no-files-found: warn

- name: 📜 Test report
if: ${{ steps.changes.outputs.app == 'true' && matrix.os == 'ubuntu-latest' }}
uses: phoenix-actions/test-reporting@v15
with:
name: 📜 Test report
path: 'reports/jest-*.xml'
reporter: jest-junit
ci:
uses: raven-actions/.workflows/.github/workflows/__ci-testcov.yml@main
secrets: inherit

- name: 📜 Coverage report
if: ${{ steps.changes.outputs.app == 'true' && matrix.os == 'ubuntu-latest' }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/cobertura-coverage.xml
4 changes: 2 additions & 2 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
token: ${{ steps.get-token.outputs.token }}

- name: 🚧 Setup pnpm
uses: pnpm/action-setup@v4
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
version: 9
run_install: false
Expand All @@ -62,7 +62,7 @@ jobs:
cache: pnpm

- name: 🔀 Install dependencies
run: pnpm install --frozen-lockfile
run: pnpm deps:ci

- name: 🏗️ Build
run: pnpm build:ci
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"run:dev": "pnpm dlx @vercel/ncc run ./src/index.ts",
"run": "node dist/index.js",
"deps:ck": "pnpm outdated --long",
"deps": "pnpm update --latest"
"deps:up": "pnpm update --latest",
"deps:ci": "pnpm install --frozen-lockfile"
},
"dependencies": {
"@actions/core": "^1.11.1",
Expand Down

0 comments on commit e41e87d

Please sign in to comment.