-
Notifications
You must be signed in to change notification settings - Fork 1
146 lines (145 loc) · 4.15 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: CI
on:
pull_request:
push:
branches:
- main
- release
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
ci_pre:
name: CI pre
runs-on: ubuntu-latest
if: github.event_name != 'push' || !startsWith(github.event.head_commit.message, 'v')
outputs:
web: ${{ steps.web.outputs.any_changed }}
server: ${{ steps.server.outputs.any_changed }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get web changed files
id: web
uses: tj-actions/changed-files@v24
with:
files: |
.github/workflows/ci.yml
.github/workflows/build.yml
.github/workflows/deploy.yml
.github/workflows/stage.yml
.github/workflows/release.yml
CHANGELOG.md
web/**
.eslintignore
- name: Get server changed files
id: server
uses: tj-actions/changed-files@v24
with:
files: |
.github/workflows/ci.yml
.github/workflows/build.yml
.github/workflows/deploy.yml
.github/workflows/stage.yml
.github/workflows/release.yml
CHANGELOG.md
server/**
ci_web:
name: CI web
needs: ci_pre
if: ${{ needs.ci_pre.outputs.web == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: web
steps:
- uses: actions/setup-node@v3
with:
node-version: lts/*
- uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3
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-
- name: Install
run: yarn install
- name: Lint
run: yarn run lint
- name: Test
run: yarn coverage
- name: codecov
uses: codecov/codecov-action@v2
with:
flags: web
- name: Check translations
run: yarn i18n --fail-on-update
- name: Build
run: yarn build
- name: Build extension
run: yarn build:ext
- name: Pack
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release'
run: mv dist reearth-marketplace-web && tar -zcvf reearth-marketplace-web.tar.gz reearth-marketplace-web
- uses: actions/upload-artifact@v3
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release'
with:
name: reearth-marketplace-web
path: web/reearth-marketplace-web.tar.gz
if-no-files-found: error
ci_server:
name: CI server
needs: ci_pre
if: ${{ needs.ci_pre.outputs.server == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: server
services:
mongo:
image: mongo:4.4-focal
ports:
- 27017:27017
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
- name: checkout
uses: actions/checkout@v3
- name: cache
uses: actions/cache@v3
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@v3
with:
version: v1.49
working-directory: server
args: --timeout=10m
- name: test
run: go test ./... -v -race -coverprofile=coverage.txt -covermode=atomic
env:
REEARTH_MARKETPLACE_DB: mongodb://localhost
- name: codecov
uses: codecov/codecov-action@v2
with:
flags: server
file: coverage.txt
ci:
name: CI
runs-on: ubuntu-latest
needs:
- ci_web
- ci_server
if: ${{ ! failure() }}
steps:
- run: echo succeeded