Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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/go/pkg/mod
/home/runner/.cache/go-build
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@v3
with:
node-version: '${{ inputs.node-version }}'

- name: get yarn cache dir
id: yarn-cache-dir
shell: bash
run: echo "YARN_CACHE_DIR=$(yarn cache dir)" >> $GITHUB_ENV

- name: yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ env.YARN_CACHE_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-
191 changes: 41 additions & 150 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
- "*"

env:
# go needs absolute directories, using the $HOME variable doesn't work here.
DOWNLOAD_CACHE: /home/runner/work/download_cache

# If you change this value, please change it in the following files as well:
# /Dockerfile
# /dev.Dockerfile
Expand All @@ -31,33 +28,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 +67,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 +95,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 +129,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 +157,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 +180,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 +200,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 +219,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
3 changes: 2 additions & 1 deletion tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN cd /tmp \
&& mkdir -p /tmp/build/.modcache \
&& cd /tmp/tools \
&& go install -trimpath -tags=tools github.com/golangci/golangci-lint/cmd/golangci-lint \
&& chmod -R 777 /tmp/build/
&& chmod -R 777 /tmp/build/ \
&& git config --global --add safe.directory /build

WORKDIR /build