Skip to content

Commit

Permalink
feat: create action (#5)
Browse files Browse the repository at this point in the history
* feat: create action

* fix: update action

* fix: update action

* auto linter

* auto linter cd

* auto linter test

* lint fix

* checkout specific branch

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
ManasC478 and github-actions[bot] authored Oct 2, 2024
1 parent 13eb745 commit 7116c81
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 46 deletions.
29 changes: 29 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Setup
description: "Setup Bun"

inputs:
os:
description: "Runner OS"
required: true

runs:
using: "composite"
steps:
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Cache Bun dependencies
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ inputs.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ inputs.os }}-bun-
- name: Install dependencies
shell: bash
run: |
cd server
bun install
67 changes: 21 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CI
on:
push:
branches:
- '**' # currently run on all branches
- "**" # currently run on all branches
pull_request:
types: [opened, synchronize, reopened]

Expand All @@ -14,23 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
- uses: ./.github/actions/setup
with:
bun-version: latest

- name: Cache Bun dependencies
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: |
cd server
bun install
os: ${{ runner.os }}

- name: Run tests
run: |
Expand All @@ -41,24 +27,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
ref: ${{ github.event.pull_request.head.ref }}

- name: Cache Bun dependencies
uses: actions/cache@v4
- uses: ./.github/actions/setup
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
os: ${{ runner.os }}

- name: Install dependencies
- name: Lint fix
run: |
cd server
bun install
cd server/
bun lint --fix
- name: Commit lint fix
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if ! git diff --exit-code > /dev/null
then
git commit -a -m "lint fix"
git push
fi
- name: Run linter
run: |
Expand All @@ -70,23 +59,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Cache Bun dependencies
uses: actions/cache@v4
- uses: ./.github/actions/setup
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: |
cd server
bun install
os: ${{ runner.os }}

- name: Run typecheck
run: |
Expand Down
Empty file added action.yml
Empty file.

0 comments on commit 7116c81

Please sign in to comment.