Skip to content

Commit

Permalink
GitHub: extract common steps
Browse files Browse the repository at this point in the history
  • Loading branch information
guggero committed Jan 5, 2023
1 parent 4050fe5 commit 0ac534c
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 147 deletions.
32 changes: 32 additions & 0 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "Setup Golang environment"
description: "A reusable workflow that's used to set up the Go environment and cache."
inputs:
go-version:
description: "The version of Golang to set up"
required: true

runs:
using: "composite"

steps:
- name: set git config
shell: bash
run: |
git config --global core.eol lf
git config --global core.autocrlf false
- name: setup go ${{ inputs.go-version }}
uses: actions/setup-go@v3
with:
go-version: '${{ inputs.go-version }}'

- name: go cache
uses: actions/cache@v3
with:
path: /home/runner/work/go
key: litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
litd-${{ runner.os }}-go-${{ inputs.go-version }}-${{ github.job }}-
litd-${{ runner.os }}-go-${{ inputs.go-version }}-
litd-${{ runner.os }}-go-
37 changes: 37 additions & 0 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Setup Node environment"
description: "A reusable workflow that's used to set up the Node environment and cache."
inputs:
node-version:
description: "The version of Node to set up"
required: true

runs:
using: "composite"

steps:
- name: set git config
shell: bash
run: |
git config --global core.eol lf
git config --global core.autocrlf false
- name: setup nodejs v${{ inputs.node-version }}
uses: actions/setup-node@v1
with:
node-version: '${{ inputs.node-version }}'

- name: get yarn cache dir
id: yarn-cache-dir
shell: bash
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: litd-${{ runner.os }}-yarn-${{ inputs.node-version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
litd-${{ runner.os }}-yarn-${{ inputs.node-version }}-${{ hashFiles('**/yarn.lock') }}
litd-${{ runner.os }}-yarn-${{ inputs.node-version }}-
litd-${{ runner.os }}-yarn-
188 changes: 41 additions & 147 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,15 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: set git config
run: |
git config --global core.eol lf
git config --global core.autocrlf false
- name: git checkout
uses: actions/checkout@v2

- name: setup nodejs v${{ matrix.node_version }}
uses: actions/setup-node@v1
uses: actions/checkout@v3
with:
node-version: ${{ matrix.node_version }}

- name: get yarn cache dir
id: yarn-cache-dir
run: echo "::set-output name=dir::$(yarn cache dir)"
fetch-depth: 0

- name: yarn cache
uses: actions/cache@v2
id: yarn-cache
- name: setup nodejs ${{ matrix.node_version }}
uses: ./.github/actions/setup-node
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node_version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ matrix.node_version }}-${{ hashFiles('**/yarn.lock') }}
${{ runner.os }}-yarn-${{ matrix.node_version }}-
${{ runner.os }}-yarn-
node-version: '${{ matrix.node_version }}'

- name: install dependencies
working-directory: ./app
Expand Down Expand Up @@ -88,43 +70,20 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- name: Set git to use LF
run: |
git config --global core.eol lf
git config --global core.autocrlf false
- name: git checkout
uses: actions/checkout@v2

- name: go cache
uses: actions/cache@v2
uses: actions/checkout@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go_version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go_version }}-${{ hashFiles('**/go.sum') }}
${{ runner.os }}-go-${{ matrix.go_version }}-
${{ runner.os }}-go-
- name: get yarn cache dir
id: yarn-cache-dir
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: yarn cache
uses: actions/cache@v2
id: yarn-cache
fetch-depth: 0

- name: setup nodejs ${{ matrix.node_version }}
uses: ./.github/actions/setup-node
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-16.x-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-16.x-${{ hashFiles('**/yarn.lock') }}
${{ runner.os }}-yarn-16.x-
${{ runner.os }}-yarn-
- name: setup go v${{ matrix.go_version }}
uses: actions/setup-go@v2
node-version: '${{ matrix.node_version }}'

- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
go-version: '~${{ matrix.go_version }}'
go-version: '${{ env.GO_VERSION }}'

- name: build backend binary
run: make build
Expand All @@ -139,52 +98,25 @@ jobs:
name: RPC proto compilation check
runs-on: ubuntu-latest
steps:
- name: set git config
run: |
git config --global core.eol lf
git config --global core.autocrlf false
- name: git checkout
uses: actions/checkout@v2

- name: setup nodejs v16.x
uses: actions/setup-node@v1
uses: actions/checkout@v3
with:
node-version: 16.x
fetch-depth: 0

- name: download cache
uses: actions/cache@v1
- name: setup nodejs ${{ matrix.node_version }}
uses: ./.github/actions/setup-node
with:
path: /home/runner/work/download_cache
key: litd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
restore-keys: |
litd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
litd-${{ runner.os }}-download-
- name: get yarn cache dir
id: yarn-cache-dir
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: yarn cache
uses: actions/cache@v2
id: yarn-cache
node-version: '${{ matrix.node_version }}'

- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node_version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ matrix.node_version }}-${{ hashFiles('**/yarn.lock') }}
${{ runner.os }}-yarn-${{ matrix.node_version }}-
${{ runner.os }}-yarn-
go-version: '${{ env.GO_VERSION }}'

- name: install dependencies
working-directory: ./app
run: yarn

- name: setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: '${{ env.GO_VERSION }}'

- name: compile rpc for golang
run: make rpc

Expand All @@ -200,23 +132,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: go cache
uses: actions/cache@v1
with:
path: /home/runner/work/go
key: litd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
litd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
litd-${{ runner.os }}-go-${{ env.GO_VERSION }}-${{ github.job }}-
litd-${{ runner.os }}-go-${{ env.GO_VERSION }}-
litd-${{ runner.os }}-go-
- name: setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'

Expand All @@ -239,12 +160,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'

Expand All @@ -262,12 +183,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'

Expand All @@ -282,12 +203,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
uses: ./.github/actions/setup-go
with:
go-version: '${{ env.GO_VERSION }}'

Expand All @@ -301,51 +222,24 @@ jobs:
name: integration test
runs-on: ubuntu-latest
steps:
- name: set git config
run: |
git config --global core.eol lf
git config --global core.autocrlf false
- name: git checkout
uses: actions/checkout@v2

- name: setup nodejs v${{ matrix.node_version }}
uses: actions/setup-node@v1
uses: actions/checkout@v3
with:
node-version: 16.x
fetch-depth: 0

- name: download cache
uses: actions/cache@v1
- name: setup nodejs ${{ matrix.node_version }}
uses: ./.github/actions/setup-node
with:
path: /home/runner/work/download_cache
key: litd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
restore-keys: |
litd-${{ runner.os }}-download-${{ hashFiles('**/install_protoc.sh') }}
litd-${{ runner.os }}-download-
- name: get yarn cache dir
id: yarn-cache-dir
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: yarn cache
uses: actions/cache@v2
id: yarn-cache
node-version: '${{ matrix.node_version }}'

- name: setup go ${{ env.GO_VERSION }}
uses: ./.github/actions/setup-go
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node_version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ matrix.node_version }}-${{ hashFiles('**/yarn.lock') }}
${{ runner.os }}-yarn-${{ matrix.node_version }}-
${{ runner.os }}-yarn-
go-version: '${{ env.GO_VERSION }}'

- name: install dependencies
working-directory: ./app
run: yarn

- name: setup go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: '${{ env.GO_VERSION }}'

- name: run check
run: make itest

0 comments on commit 0ac534c

Please sign in to comment.