Skip to content

Commit 6da740c

Browse files
committed
ci: add fork-only workflow for feature branches and stacked PRs
The upstream workflows only trigger on push to main and on pull requests with base main/release-*, so fork feature branches and stacked PRs get no CI at all. fork-ci.yml mirrors golangci-lint, migration-script-lint, unit-test, e2e (mysql), config-ui, the ASF header check and the grafana dashboard check for every other branch and PR base. It is guarded with github.repository != 'apache/devlake' so it never runs upstream.
1 parent d8e0b7e commit 6da740c

1 file changed

Lines changed: 185 additions & 0 deletions

File tree

.github/workflows/fork-ci.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# Fork-only CI.
19+
#
20+
# The upstream workflows (test.yml, test-e2e.yml, config-ui.yml,
21+
# asf-header-check.yml, ...) only trigger on `push` to `main` and on
22+
# `pull_request` with base `main`/`release-*`. In this fork we work on
23+
# feature branches (`pr/**`, `fix/**`, ...) and often stack pull requests on
24+
# top of each other, so those workflows never run before a PR is opened
25+
# upstream.
26+
#
27+
# This workflow mirrors the upstream checks for every other branch/base, so
28+
# CI failures show up in the fork immediately. It is deliberately guarded so
29+
# it never runs in `apache/devlake` should the file ever be merged upstream.
30+
name: fork-ci
31+
32+
on:
33+
push:
34+
branches-ignore:
35+
- main
36+
pull_request:
37+
branches-ignore:
38+
- main
39+
workflow_dispatch:
40+
41+
concurrency:
42+
group: fork-ci-${{ github.workflow }}-${{ github.head_ref || github.ref }}
43+
cancel-in-progress: true
44+
45+
jobs:
46+
golangci-lint:
47+
name: lint (go)
48+
if: github.repository != 'apache/devlake'
49+
runs-on: ubuntu-latest
50+
container: mericodev/lake-builder:latest
51+
steps:
52+
- uses: actions/checkout@v6
53+
- run: git config --global --add safe.directory $(pwd)
54+
- name: generate mock
55+
run: |
56+
go version
57+
cd backend
58+
make mock
59+
- name: golangci-lint
60+
uses: golangci/golangci-lint-action@v9
61+
with:
62+
version: v2.12.2
63+
working-directory: ./backend
64+
65+
migration-script-lint:
66+
name: migration-script-lint
67+
if: github.repository != 'apache/devlake'
68+
runs-on: ubuntu-latest
69+
container: mericodev/lake-builder:latest
70+
steps:
71+
- uses: actions/checkout@v6
72+
- run: git config --global --add safe.directory $(pwd)
73+
- name: migration script linting
74+
run: |
75+
go version
76+
cd backend
77+
go run core/migration/linter/main.go -p backend $(find . -path "**/migrationscripts/**.go")
78+
79+
unit-test:
80+
name: unit-test
81+
if: github.repository != 'apache/devlake'
82+
runs-on: ubuntu-latest
83+
container: mericodev/lake-builder:latest
84+
steps:
85+
- uses: actions/checkout@v6
86+
- run: git config --global --add safe.directory $(pwd)
87+
- name: Build Python
88+
run: |
89+
cd backend
90+
make build-python
91+
- name: Cache go build
92+
uses: actions/cache@v5
93+
with:
94+
path: |
95+
~/.cache/go-build
96+
${{ env.GOPATH }}/pkg/mod
97+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
98+
restore-keys: |
99+
${{ runner.os }}-go-
100+
- name: Unit tests
101+
run: |
102+
go version
103+
cp env.example .env
104+
cd backend
105+
make unit-test
106+
107+
e2e-mysql:
108+
name: e2e (mysql)
109+
if: github.repository != 'apache/devlake'
110+
runs-on: ubuntu-latest
111+
services:
112+
db:
113+
image: mysql:8
114+
env:
115+
MYSQL_DATABASE: lake
116+
MYSQL_USER: merico
117+
MYSQL_PASSWORD: merico
118+
MYSQL_ROOT_PASSWORD: root
119+
container: mericodev/lake-builder:latest
120+
steps:
121+
- uses: actions/checkout@v6
122+
- run: git config --global --add safe.directory $(pwd)
123+
- name: Build Python
124+
run: |
125+
cd backend
126+
make build-python
127+
- name: Cache go build
128+
uses: actions/cache@v5
129+
with:
130+
path: |
131+
~/.cache/go-build
132+
${{ env.GOPATH }}/pkg/mod
133+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
134+
restore-keys: |
135+
${{ runner.os }}-go-
136+
- name: Test-mysql
137+
env:
138+
DB_URL: mysql://root:root@db:3306/lake?charset=utf8mb4&parseTime=True
139+
E2E_DB_URL: mysql://root:root@db:3306/lake?charset=utf8mb4&parseTime=True
140+
run: |
141+
go version
142+
cp env.example .env
143+
cd backend
144+
make e2e-test-go-plugins
145+
make e2e-test
146+
147+
config-ui:
148+
name: config-ui
149+
if: github.repository != 'apache/devlake'
150+
runs-on: ubuntu-latest
151+
steps:
152+
- uses: actions/checkout@v6
153+
- name: Set up Node.js
154+
uses: actions/setup-node@v6
155+
with:
156+
node-version: '24'
157+
cache: 'yarn'
158+
cache-dependency-path: config-ui/yarn.lock
159+
- name: Install with Yarn
160+
run: cd config-ui; yarn
161+
- name: Run Lint
162+
run: cd config-ui; yarn tsc && yarn lint
163+
164+
asf-header-check:
165+
name: check Apache license header
166+
if: github.repository != 'apache/devlake'
167+
runs-on: ubuntu-24.04
168+
steps:
169+
- uses: actions/checkout@v6
170+
- name: Check License Header
171+
uses: apache/skywalking-eyes@main
172+
173+
grafana-dashboards-check:
174+
name: check grafana dashboards
175+
if: github.repository != 'apache/devlake'
176+
runs-on: ubuntu-24.04
177+
steps:
178+
- uses: actions/checkout@v6
179+
- name: Check grafana dashboards whether using mysql uid
180+
run: |
181+
if grep '"type": "mysql"' grafana/dashboards/*; then
182+
echo "There are dashboards which use mysql uid as datasource"
183+
exit 1
184+
fi
185+

0 commit comments

Comments
 (0)