Skip to content

Commit

Permalink
chore: introduce prepare composite action
Browse files Browse the repository at this point in the history
  • Loading branch information
lozinsky committed Oct 10, 2023
1 parent 18baecf commit c3dc0b9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 57 deletions.
23 changes: 23 additions & 0 deletions .github/actions/prepare/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Prepare

runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3

- name: Store cache path
run: echo "cache_path=$(npm config get cache)" >> $GITHUB_ENV
shell: sh

- name: Restore cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
shell: sh
23 changes: 4 additions & 19 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,14 @@ jobs:
publish:
name: Publish
runs-on: ubuntu-latest

steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v3

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

- name: Store cache path
run: echo "cache_path=$(npm config get cache)" >> $GITHUB_ENV

- name: Restore cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Prepare
uses: ./.github/actions/prepare

- name: Run code build
- name: Build
run: npm run build

- name: Publish
Expand Down
46 changes: 8 additions & 38 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,25 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v3

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

- name: Store cache path
run: echo "cache_path=$(npm config get cache)" >> $GITHUB_ENV

- name: Restore cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Prepare
uses: ./.github/actions/prepare

- name: Run code lint
- name: Lint
run: npm run lint

test:
name: Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v3

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

- name: Store cache path
run: echo "cache_path=$(npm config get cache)" >> $GITHUB_ENV

- name: Restore cache
uses: actions/cache@v3
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: Prepare
uses: ./.github/actions/prepare

- name: Run code test
- name: Test
run: npm test

0 comments on commit c3dc0b9

Please sign in to comment.