build: enhance GitHub actions

This commit is contained in:
EnixCoda 2022-07-17 17:19:10 +08:00
parent d279b475bc
commit 0e4f9184f9
4 changed files with 142 additions and 58 deletions

View file

@ -1,35 +1,19 @@
name: CI
name: Generate build for reuse
on:
push:
branches:
- '**'
paths-ignore:
- 'server/**'
pull_request:
branches:
- '**'
paths-ignore:
- 'server/**'
workflow_call:
jobs:
build-and-test:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Retrieve vscode icons
uses: actions/checkout@v2
with:
repository: 'vscode-icons/vscode-icons'
path: 'vscode-icons'
- uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Dependencies
- name: Cache deps
uses: actions/cache@v1
id: yarn-cache
with:
@ -44,17 +28,19 @@ jobs:
run: |
yarn
- name: Retrieve vscode icons
uses: actions/checkout@v3
with:
repository: 'vscode-icons/vscode-icons'
path: 'vscode-icons'
- name: Build
run: |
make build
- name: Unit Test
run: |
yarn jest src
- name: E2E Test
uses: mujo-code/puppeteer-headful@master
env:
CI: 'true'
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
args: yarn test
name: dist
path: |
dist

View file

@ -7,39 +7,23 @@ on:
- release-*
jobs:
build:
uses: ./.github/workflows/build.yml
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Get the ref
id: get_ref
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
- uses: actions/checkout@v3
- uses: actions/checkout@v1
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache deps
uses: actions/cache@v1
id: yarn-cache
- name: Download a built dist artifact
uses: actions/download-artifact@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
name: dist
- name: Retrieve vscode icons
uses: actions/checkout@v2
with:
repository: 'vscode-icons/vscode-icons'
path: 'vscode-icons'
- name: Build
run: |
yarn
make build
- uses: ./.github/workflows/version.yml
id: version
- name: Create Release
id: create_release
@ -47,8 +31,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_ref.outputs.VERSION }}
release_name: ${{ steps.get_ref.outputs.VERSION }}
tag_name: ${{ steps.version.outputs.VERSION }}
release_name: ${{ steps.version.outputs.VERSION }}
draft: false
prerelease: false

95
.github/workflows/tests.yml vendored Normal file
View file

@ -0,0 +1,95 @@
name: Tests
on:
push:
branches:
- '**'
paths-ignore:
- 'server/**'
pull_request:
branches:
- '**'
paths-ignore:
- 'server/**'
# Runs everyday to detect GitHub update in time
schedule:
- cron: '0 0 * * *'
jobs:
build:
uses: ./.github/workflows/build.yml
e2e-test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download a built dist artifact
uses: actions/download-artifact@v3
with:
name: dist
# Found no way to reuse cache steps
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache deps
uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
run: |
yarn
- name: E2E Test
uses: mujo-code/puppeteer-headful@master
env:
CI: 'true'
with:
args: yarn test
unit-test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download a built dist artifact
uses: actions/download-artifact@v3
with:
name: dist
# Found no way to reuse cache steps
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache deps
uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
run: |
yarn
- name: Unit Test
run: |
yarn jest src

19
.github/workflows/version.yml vendored Normal file
View file

@ -0,0 +1,19 @@
name: Get VERSION for referencing
on:
workflow_call:
outputs:
VERSION:
description: "The VERSION string"
value: ${{ jobs.build.outputs.VERSION }}
jobs:
get-version:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.get_ref.outputs.VERSION }}
steps:
- name: Get the ref
id: get_ref
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)