Skip to content

Commit a479e76

Browse files
committed
Move lint to separate workflow, use concurrency feature to cancel runs (nginx#155)
1 parent 447d625 commit a479e76

File tree

4 files changed

+77
-51
lines changed

4 files changed

+77
-51
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ defaults:
2222
run:
2323
shell: bash
2424

25-
env:
26-
DOCKER_BUILDKIT: 1
27-
GOLANGCI_TIMEOUT: 10m0s
25+
concurrency:
26+
group: ${{ github.ref_name }}-ci
27+
cancel-in-progress: true
2828

2929
jobs:
3030

@@ -38,10 +38,6 @@ jobs:
3838
version: ${{ steps.vars.outputs.version }}
3939
date: ${{ steps.vars.outputs.date }}
4040
steps:
41-
- name: Cancel Previous Runs
42-
uses: styfle/cancel-workflow-action@0.9.1
43-
with:
44-
access_token: ${{ secrets.GITHUB_TOKEN }}
4541
- name: Checkout Repository
4642
uses: actions/checkout@v3
4743
- name: Output Variables
@@ -53,43 +49,6 @@ jobs:
5349
echo "::set-output name=version::$(grep "VERSION = " Makefile | cut -d " " -f 3)"
5450
echo "::set-output name=date::$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
5551
56-
lint:
57-
name: Lint
58-
runs-on: ubuntu-20.04
59-
needs: vars
60-
steps:
61-
- name: Checkout Repository
62-
uses: actions/checkout@v3
63-
- name: Setup Golang Environment
64-
uses: actions/setup-go@v3
65-
with:
66-
go-version: ${{ needs.vars.outputs.go_version }}
67-
- name: Lint Code
68-
uses: golangci/golangci-lint-action@v3.2.0
69-
with:
70-
args: --timeout ${{ env.GOLANGCI_TIMEOUT }}
71-
72-
njs-lint:
73-
name: NJS Lint
74-
runs-on: ubuntu-20.04
75-
steps:
76-
- name: Checkout Repository
77-
uses: actions/checkout@v2
78-
- name: Run Prettier on NJS code
79-
id: prettier-run
80-
uses: rutajdash/prettier-cli-action@v1.0.0
81-
with:
82-
config_path: ${{ github.workspace }}/internal/nginx/modules/.prettierrc
83-
file_pattern: ${{ github.workspace }}/internal/nginx/modules/**/*.js
84-
prettier_version: 2.6.2
85-
- name: Prettier Output
86-
if: ${{ failure() }}
87-
shell: bash
88-
run: |
89-
echo "The following files are not formatted:"
90-
echo "${{steps.prettier-run.outputs.prettier_output}}"
91-
echo "Run \"make njs-fmt\" locally to format the code"
92-
9352
unit-tests:
9453
name: Unit Tests
9554
runs-on: ubuntu-20.04
@@ -126,7 +85,7 @@ jobs:
12685
binary:
12786
name: Build Binary
12887
runs-on: ubuntu-20.04
129-
needs: [vars, lint]
88+
needs: vars
13089
steps:
13190
- name: Checkout Repository
13291
uses: actions/checkout@v3

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ on:
2020
schedule:
2121
- cron: '39 13 * * 6'
2222

23+
concurrency:
24+
group: ${{ github.ref_name }}-codeql
25+
cancel-in-progress: true
26+
2327
jobs:
2428
analyze:
2529
name: Analyze

.github/workflows/fossa.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,18 @@ on:
55
branches:
66
- main
77

8-
jobs:
8+
concurrency:
9+
group: ${{ github.ref_name }}-fossa
10+
cancel-in-progress: true
911

12+
jobs:
1013
scan:
1114
name: Fossa
1215
runs-on: ubuntu-20.04
1316
steps:
14-
- name: Cancel Previous Runs
15-
uses: styfle/cancel-workflow-action@0.9.1
16-
with:
17-
access_token: ${{ secrets.GITHUB_TOKEN }}
1817
- name: Checkout Repository
1918
uses: actions/checkout@v3
2019
- name: Scan
2120
uses: fossas/fossa-action@v1
2221
with:
23-
api-key: ${{ secrets.FOSSA_TOKEN }}
22+
api-key: ${{ secrets.FOSSA_TOKEN }}

.github/workflows/lint.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '**.md'
9+
pull_request:
10+
branches:
11+
- main
12+
paths-ignore:
13+
- '**.md'
14+
types:
15+
- opened
16+
- reopened
17+
- synchronize
18+
19+
defaults:
20+
run:
21+
shell: bash
22+
23+
concurrency:
24+
group: ${{ github.ref_name }}-lint
25+
cancel-in-progress: true
26+
27+
jobs:
28+
29+
lint:
30+
name: Lint
31+
runs-on: ubuntu-20.04
32+
steps:
33+
- name: Checkout Repository
34+
uses: actions/checkout@v3
35+
- name: Setup Golang Environment
36+
uses: actions/setup-go@v3
37+
with:
38+
go-version-file: go.mod
39+
- name: Lint Code
40+
uses: golangci/golangci-lint-action@v3.2.0
41+
with:
42+
args: --timeout 10m0s
43+
only-new-issues: true
44+
45+
njs-lint:
46+
name: NJS Lint
47+
runs-on: ubuntu-20.04
48+
steps:
49+
- name: Checkout Repository
50+
uses: actions/checkout@v2
51+
- name: Run Prettier on NJS code
52+
id: prettier-run
53+
uses: rutajdash/prettier-cli-action@v1.0.0
54+
with:
55+
config_path: ${{ github.workspace }}/internal/nginx/modules/.prettierrc
56+
file_pattern: ${{ github.workspace }}/internal/nginx/modules/**/*.js
57+
prettier_version: 2.6.2
58+
- name: Prettier Output
59+
if: ${{ failure() }}
60+
shell: bash
61+
run: |
62+
echo "The following files are not formatted:"
63+
echo "${{steps.prettier-run.outputs.prettier_output}}"
64+
echo "Run \"make njs-fmt\" locally to format the code"

0 commit comments

Comments
 (0)