Skip to content

Commit 8c657fc

Browse files
ci: Sync .github directory from develop (#2655)
1 parent 5c3ef79 commit 8c657fc

15 files changed

+1193
-169
lines changed

.github/autolabeler.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
template: "Mandatory field" #https://github.com/release-drafter/release-drafter/blob/master/bin/generate-schema.js#L15
2+
autolabeler:
3+
- label: 'breaking'
4+
body:
5+
- '/BREAKING CHANGE/i'
6+
- label: 'fix'
7+
title:
8+
- '/^fix:/'
9+
- label: 'feat'
10+
title:
11+
- '/^feat:/'
12+
- label: 'docs'
13+
title:
14+
- '/^docs:/'
15+
- label: 'chore'
16+
title:
17+
- '/^chore:/'
18+
- label: 'ci'
19+
title:
20+
- '/^ci:/'
21+
- label: 'perf'
22+
title:
23+
- '/^perf:/'
24+
- label: 'refactor'
25+
title:
26+
- '/^refactor:/'
27+
- label: 'style'
28+
title:
29+
- '/^style:/'
30+
- label: 'test'
31+
title:
32+
- '/^test:/'

.github/pr-title-checker-config.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"LABEL": {
3+
"name": "title needs formatting",
4+
"color": "EEEEEE"
5+
},
6+
"CHECKS": {
7+
"prefixes": [
8+
"fix: ",
9+
"feat: ",
10+
"docs: ",
11+
"chore: ",
12+
"ci: ",
13+
"perf: ",
14+
"refactor: ",
15+
"style: ",
16+
"test: "
17+
],
18+
"ignoreLabels": [
19+
"skip-changelog",
20+
"skip-ci"
21+
]
22+
},
23+
"MESSAGES": {
24+
"success": "PR title is valid",
25+
"failure": "PR title is invalid",
26+
"notice": "Valid prefixes are: fix, feat, docs, chore, ci, perf, refactor, style, test."
27+
}
28+
}

.github/workflows/bandit.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Bandit"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
head_sha:
7+
required: true
8+
type: string
9+
repo:
10+
required: true
11+
type: string
12+
default: heartexlabs/label-studio
13+
14+
env:
15+
BANDIT_VERSION: 1.7.4
16+
PROJECT_PATH: 'label_studio/'
17+
REPORT_PATH: 'bandit_results/bandit_security_report.txt'
18+
ACTIONS_STEP_DEBUG: '${{ secrets.ACTIONS_STEP_DEBUG }}'
19+
20+
jobs:
21+
bandit:
22+
name: "Bandit"
23+
timeout-minutes: 2
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: hmarr/[email protected]
27+
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
with:
31+
repository: ${{ inputs.repo }}
32+
ref: ${{ inputs.head_sha }}
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v4
36+
with:
37+
python-version: '3.7'
38+
39+
- name: Install Bandit
40+
run: |
41+
pip install bandit==$BANDIT_VERSION
42+
43+
- name: Run Bandit
44+
run: |
45+
mkdir -p bandit_results
46+
touch ${{ env.REPORT_PATH }}
47+
bandit -r $PROJECT_PATH -o ${{ env.REPORT_PATH }} -f 'txt' -ll
48+
49+
- name: Print scan results
50+
if: always()
51+
run: cat ${{ env.REPORT_PATH }}
52+
53+
- uses: actions/upload-artifact@v3
54+
if: always()
55+
with:
56+
name: Security check results
57+
path: ${{ env.REPORT_PATH }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Cancel PR CI/CD pipeline"
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
- converted_to_draft
8+
- locked
9+
branches:
10+
- develop
11+
12+
concurrency:
13+
group: CI/CD Pipeline-${{ github.event.pull_request.number || github.event.pull_request.head.ref || github.ref_name }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
cancel:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: hmarr/[email protected]
21+
- run: echo CI/CD Pipeline-${{ github.event.pull_request.number || github.event.pull_request.head.ref || github.ref_name }}

.github/workflows/cicd_pipeline.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: "CI/CD Pipeline"
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- 'ls-release/**'
8+
paths:
9+
- deploy/**
10+
- label_studio/**
11+
- setup.py
12+
- .github/workflows/cicd_pipeline.yml
13+
- .github/workflows/pr-labeler.yml
14+
- .github/workflows/submodules-validator.yml
15+
- .github/workflows/gitleaks.yml
16+
- .github/workflows/bandit.yml
17+
- .github/workflows/docker-build.yml
18+
- .github/workflows/tests.yml
19+
pull_request_target:
20+
types:
21+
- opened
22+
- synchronize
23+
- reopened
24+
- ready_for_review
25+
branches:
26+
- develop
27+
- 'ls-release/**'
28+
29+
concurrency:
30+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.pull_request.head.ref || github.ref }}
31+
cancel-in-progress: true
32+
33+
jobs:
34+
changed_files:
35+
name: "Changed files"
36+
runs-on: ubuntu-latest
37+
outputs:
38+
src: ${{ steps.changes.outputs.src }}
39+
frontend: ${{ steps.changes.outputs.frontend }}
40+
docker: ${{ steps.changes.outputs.docker }}
41+
commit-message: ${{ steps.commit-details.outputs.message }}
42+
timeout-minutes: 5
43+
steps:
44+
- uses: hmarr/[email protected]
45+
46+
- name: Checkout
47+
if: github.event_name == 'push'
48+
uses: actions/checkout@v3
49+
with:
50+
ref: ${{ github.ref }}
51+
52+
- uses: dorny/paths-filter@v2
53+
id: changes
54+
with:
55+
filters: |
56+
src:
57+
- 'label_studio/!(frontend)/**'
58+
- 'deploy/requirements**'
59+
- 'setup.py'
60+
frontend:
61+
- 'label_studio/frontend/**'
62+
docker:
63+
- 'label_studio/**'
64+
- 'deploy/**'
65+
- 'Dockerfile**'
66+
- 'setup.py'
67+
- '.github/workflows/cicd_pipeline.yml'
68+
- '.github/workflows/docker-build.yml'
69+
70+
- uses: actions/github-script@v6
71+
id: commit-details
72+
with:
73+
github-token: ${{ secrets.GIT_PAT }}
74+
script: |
75+
const { repo, owner } = context.repo;
76+
const { data: commit } = await github.rest.repos.getCommit({
77+
owner,
78+
repo,
79+
ref: '${{ github.event.pull_request.head.sha || github.event.after }}'
80+
});
81+
core.setOutput("message", commit.commit.message);
82+
83+
pr_labeler:
84+
name: "Validate"
85+
if: github.event_name == 'pull_request_target'
86+
uses: heartexlabs/label-studio/.github/workflows/pr-labeler.yml@develop
87+
secrets: inherit
88+
89+
validate_submodules:
90+
name: "Validate"
91+
uses: heartexlabs/label-studio/.github/workflows/submodules-validator.yml@develop
92+
with:
93+
repo: ${{ github.event.pull_request.head.repo.full_name || github.event.repo.name || github.repository }}
94+
head_sha: ${{ github.event.pull_request.head.sha || github.event.after }}
95+
base_sha: ${{ github.event.pull_request.base.sha || github.event.before }}
96+
target_branch: ${{ github.event.pull_request.base.ref || github.event.ref }}
97+
secrets: inherit
98+
99+
gitleaks:
100+
name: "Linter"
101+
if: github.event_name == 'pull_request_target'
102+
uses: heartexlabs/label-studio/.github/workflows/gitleaks.yml@develop
103+
with:
104+
repo: ${{ github.event.pull_request.head.repo.full_name || github.event.repo.name || github.repository }}
105+
head_sha: ${{ github.event.pull_request.head.sha || github.event.after }}
106+
base_sha: ${{ github.event.pull_request.base.sha || github.event.before }}
107+
secrets: inherit
108+
109+
bandit:
110+
name: "Linter"
111+
needs:
112+
- changed_files
113+
if: needs.changed_files.outputs.src == 'true'
114+
uses: heartexlabs/label-studio/.github/workflows/bandit.yml@develop
115+
with:
116+
repo: ${{ github.event.pull_request.head.repo.full_name || github.event.repo.name || github.repository }}
117+
head_sha: ${{ github.event.pull_request.head.sha || github.event.after }}
118+
secrets: inherit
119+
120+
frontend-build:
121+
name: "Build"
122+
needs:
123+
- changed_files
124+
if: |
125+
github.event_name == 'pull_request_target' &&
126+
needs.changed_files.outputs.frontend == 'true' &&
127+
needs.changed_files.outputs.commit-message != 'Build frontend'
128+
uses: heartexlabs/label-studio/.github/workflows/frontend-build.yml@develop
129+
with:
130+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
131+
secrets: inherit
132+
133+
build:
134+
name: "Build"
135+
needs:
136+
- changed_files
137+
if: github.event_name == 'push' && github.ref == 'refs/heads/develop' && needs.changed_files.outputs.docker == 'true'
138+
uses: heartexlabs/label-studio/.github/workflows/docker-build.yml@develop
139+
with:
140+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
141+
secrets: inherit
142+
143+
pytest:
144+
name: "Tests"
145+
needs:
146+
- changed_files
147+
if: needs.changed_files.outputs.src == 'true'
148+
uses: heartexlabs/label-studio/.github/workflows/tests.yml@develop
149+
with:
150+
repo: ${{ github.event.pull_request.head.repo.full_name || github.event.repo.name || github.repository }}
151+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
152+
secrets: inherit

0 commit comments

Comments
 (0)