Skip to content

Commit

Permalink
Extract test-lint into custom action, run it before all workflows
Browse files Browse the repository at this point in the history
Use on-push / on-release triggers for (pre)release workflows for lib

Should close #18
  • Loading branch information
yamalight committed Oct 21, 2024
1 parent fdeb40d commit 91db3ea
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 41 deletions.
31 changes: 31 additions & 0 deletions .github/actions/test-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Test and lint code'
description: 'Performs tests and linting of all the components in the repo'
runs:
using: 'composite'
steps:
# install bun
- name: Install bun for deployment
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
# install deps
- name: Install lib deps
working-directory: ./packages/litlytics
run: bun install --frozen-lockfile
- name: Install app deps
run: bun install --frozen-lockfile
# lib lint/check/test
- name: Run lib typecheck
working-directory: ./packages/litlytics
run: bun run typecheck
- name: Run lib tests
working-directory: ./packages/litlytics
run: bun run test:ci

# main app lint/check/test
- name: Run app eslint
run: bun run lint
- name: Run app typecheck
run: bun run typecheck
- name: Run app test
run: bun run test:ci
4 changes: 4 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

# run test-lint
- name: Test and lint
uses: ./.github/actions/test-lint

- name: Install bun for deployment
uses: oven-sh/setup-bun@v2
with:
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/prerelease-lib.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
name: Prerelease litlytics library

on:
workflow_run:
# Run after "Test and lint" workflow
workflows: ['Test and lint']
types:
- completed # Only when it's completed
branches:
- main # Only run the publish workflow for pushes to main
push:
branches: ['main'] # Only run the publish workflow for pushes to main

jobs:
publish-lib-prerelease:
Expand All @@ -25,6 +20,10 @@ jobs:
with:
fetch-depth: 2

# run test-lint
- name: Test and lint
uses: ./.github/actions/test-lint

# Check for changes in ./packages/litlytics
- name: Check if changed
id: changes
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/release-lib.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Release litlytics library

on:
workflow_run:
# Run after "Test and lint" workflow
workflows: ['Test and lint']
release:
types:
- completed # Only when it's completed
- published # run on new published releases

jobs:
publish-lib:
Expand All @@ -23,6 +21,10 @@ jobs:
with:
fetch-depth: 2

# run test-lint
- name: Test and lint
uses: ./.github/actions/test-lint

# Check for changes in ./packages/litlytics
- name: Check if changed
id: changes
Expand Down
32 changes: 2 additions & 30 deletions .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,5 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install bun for deployment
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

# install deps
- name: Install lib deps
working-directory: ./packages/litlytics
run: bun install --frozen-lockfile
- name: Install app deps
run: bun install --frozen-lockfile

# lib lint/check/test
- name: Run lib typecheck
working-directory: ./packages/litlytics
run: bun run typecheck

- name: Run lib tests
working-directory: ./packages/litlytics
run: bun run test:ci

# main app lint/check/test
- name: Run app eslint
run: bun run lint

- name: Run app typecheck
run: bun run typecheck

- name: Run app test
run: bun run test:ci
- name: Test and lint
uses: ./.github/actions/test-lint

0 comments on commit 91db3ea

Please sign in to comment.