Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(server): enhance performance #928

Merged
merged 26 commits into from
Oct 15, 2024
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
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: ci
on:
push:
branches: [main, release]
pull_request:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
web: ${{ steps.web.outputs.any_modified }}
server: ${{ steps.server.outputs.any_modified }}
worker: ${{ steps.worker.outputs.any_modified }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: changed files for web
id: web
uses: tj-actions/changed-files@v45
with:
files: |
web
.github/workflows/ci.yml
.github/workflows/ci_web.yml

- name: changed files for server
id: server
uses: tj-actions/changed-files@v45
with:
files: |
server
.github/workflows/ci.yml
.github/workflows/ci_server.yml
.github/workflows/build_server.yml

- name: changed files for worker
id: worker
uses: tj-actions/changed-files@v45
with:
files: |
worker
.github/workflows/ci.yml
.github/workflows/ci_worker.yml
.github/workflows/build_worker.yml

ci-web:
name: web
needs: prepare
if: needs.prepare.outputs.web == 'true'
uses: ./.github/workflows/ci_web.yml

ci-server:
name: server
needs: prepare
if: needs.prepare.outputs.server == 'true'
uses: ./.github/workflows/ci_server.yml

ci-worker:
name: worker
needs: prepare
if: needs.prepare.outputs.worker == 'true'
uses: ./.github/workflows/ci_worker.yml

ci:
yk-eukarya marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
needs:
- ci-web
- ci-server
- ci-worker
if: '!failure()'
steps:
- run: echo OK
85 changes: 43 additions & 42 deletions .github/workflows/ci_server.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
name: ci-server
on:
push:
branches: [main, release]
paths:
- server/**
- .github/workflows/ci_server.yml
- .github/workflows/server_build.yml
- .github/workflows/deploy_test.yml
- .github/workflows/pr_title.yml
- .github/workflows/stage.yml
- .github/workflows/release.yml
- .github/workflows/server_build.yml
pull_request:
paths:
- server/**
- .github/workflows/ci_server.yml
- .github/workflows/server_build.yml
- .github/workflows/deploy_test.yml
- .github/workflows/pr_title.yml
- .github/workflows/stage.yml
- .github/workflows/release.yml
workflow_call:
env:
GO_VERSION: "1.23"
yk-eukarya marked this conversation as resolved.
Show resolved Hide resolved

jobs:
ci:
name: ci
ci-server-lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: go setup
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61
working-directory: server
args: --config=../.golangci.yml
skip-cache: true
ci-server-i18n:
name: i18n
runs-on: ubuntu-latest
defaults:
run:
working-directory: server
steps:
- name: checkout
uses: actions/checkout@v4
- name: go setup
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: check forgotten translations
working-directory: server
run: make i18n-ci
ci-server-test:
name: test
runs-on: ubuntu-latest
services:
mongo:
image: mongo:6-focal
ports:
- 27017:27017
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.23
- name: checkout
uses: actions/checkout@v4
- name: cache
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
- name: go setup
uses: actions/setup-go@v5
with:
version: v1.61
working-directory: server
args: --config=../.golangci.yml
go-version: ${{ env.GO_VERSION }}
- name: test
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m
working-directory: server
env:
REEARTH_CMS_DB: mongodb://localhost
- name: codecov
- name: Send coverage report
uses: codecov/codecov-action@v4
with:
flags: server
file: coverage.txt
- name: check forgotten translations
run: make i18n-ci
file: coverage.txt
32 changes: 4 additions & 28 deletions .github/workflows/ci_web.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
name: ci-web
on:
push:
branches: [main, release]
paths:
- web/**
- .github/workflows/ci_web.yml
- .github/workflows/deploy_test.yml
- .github/workflows/pr_title.yml
- .github/workflows/stage.yml
- .github/workflows/release.yml
pull_request:
paths:
- web/**
- .github/workflows/ci_web.yml
- .github/workflows/deploy_test.yml
- .github/workflows/pr_title.yml
- .github/workflows/stage.yml
- .github/workflows/release.yml
workflow_call:
jobs:
ci:
name: ci
Expand All @@ -25,20 +9,12 @@ jobs:
run:
working-directory: web
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: actions/checkout@v4
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
cache: yarn
yk-eukarya marked this conversation as resolved.
Show resolved Hide resolved
cache-dependency-path: '**/yarn.lock'
- name: Install
run: yarn install
- name: Lint
Expand Down
71 changes: 29 additions & 42 deletions .github/workflows/ci_worker.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,48 @@
name: ci-worker
on:
push:
branches: [main, release]
paths:
- worker/**
- .github/workflows/ci_worker.yml
- .github/workflows/deploy_test.yml
- .github/workflows/pr_title.yml
- .github/workflows/stage.yml
- .github/workflows/release.yml
- .github/workflows/decompressor_build.yml
- .github/workflows/worker_build.yml
pull_request:
paths:
- worker/**
- .github/workflows/ci_worker.yml
- .github/workflows/deploy_test.yml
- .github/workflows/pr_title.yml
- .github/workflows/stage.yml
- .github/workflows/release.yml
workflow_call:
env:
GO_VERSION: "1.23"
yk-eukarya marked this conversation as resolved.
Show resolved Hide resolved
jobs:
ci:
name: ci
ci-server-lint:
name: lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: worker
services:
mongo:
image: mongo:6-focal
ports:
- 27017:27017
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.23
- name: checkout
uses: actions/checkout@v4
- name: cache
uses: actions/cache@v4
- name: go setup
uses: actions/setup-go@v5
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61
working-directory: worker
args: --config=../.golangci.yml
skip-cache: true
ci-server-test:
name: test
runs-on: ubuntu-latest
services:
mongo:
image: mongo:6-focal
ports:
- 27017:27017
steps:
- name: checkout
uses: actions/checkout@v4
- name: go setup
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: test
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 10m
working-directory: worker
env:
REEARTH_CMS_WORKER_DB: mongodb://localhost
- name: codecov
REEARTH_CMS_DB: mongodb://localhost
- name: Send coverage report
uses: codecov/codecov-action@v4
with:
flags: worker
file: coverage.txt
file: coverage.txt
17 changes: 15 additions & 2 deletions .github/workflows/pr_title.yml → .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PR Title Checker
name: PR
on:
pull_request:
types:
Expand All @@ -8,12 +8,17 @@ on:
- labeled
- unlabeled
jobs:
pr_title:
labeler:
name: labeler
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
title_check:
name: title check
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -27,3 +32,11 @@ jobs:
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
pr_title:
runs-on: ubuntu-latest
needs:
- labeler
- title_check
if: '!failure()'
steps:
- run: echo OK
Loading