Skip to content

Move lint to separate workflow, use concurrency feature to cancel runs #155

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

Merged
merged 1 commit into from
Jul 27, 2022
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
49 changes: 4 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ defaults:
run:
shell: bash

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

jobs:

Expand All @@ -38,10 +38,6 @@ jobs:
version: ${{ steps.vars.outputs.version }}
date: ${{ steps.vars.outputs.date }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Repository
uses: actions/checkout@v3
- name: Output Variables
Expand All @@ -53,43 +49,6 @@ jobs:
echo "::set-output name=version::$(grep "VERSION = " Makefile | cut -d " " -f 3)"
echo "::set-output name=date::$(date -u +"%Y-%m-%dT%H:%M:%SZ")"

lint:
name: Lint
runs-on: ubuntu-20.04
needs: vars
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Golang Environment
uses: actions/setup-go@v3
with:
go-version: ${{ needs.vars.outputs.go_version }}
- name: Lint Code
uses: golangci/golangci-lint-action@v3.2.0
with:
args: --timeout ${{ env.GOLANGCI_TIMEOUT }}

njs-lint:
name: NJS Lint
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Run Prettier on NJS code
id: prettier-run
uses: rutajdash/prettier-cli-action@v1.0.0
with:
config_path: ${{ github.workspace }}/internal/nginx/modules/.prettierrc
file_pattern: ${{ github.workspace }}/internal/nginx/modules/**/*.js
prettier_version: 2.6.2
- name: Prettier Output
if: ${{ failure() }}
shell: bash
run: |
echo "The following files are not formatted:"
echo "${{steps.prettier-run.outputs.prettier_output}}"
echo "Run \"make njs-fmt\" locally to format the code"

unit-tests:
name: Unit Tests
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -126,7 +85,7 @@ jobs:
binary:
name: Build Binary
runs-on: ubuntu-20.04
needs: [vars, lint]
needs: vars
steps:
- name: Checkout Repository
uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
schedule:
- cron: '39 13 * * 6'

concurrency:
group: ${{ github.ref_name }}-codeql
cancel-in-progress: true

jobs:
analyze:
name: Analyze
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/fossa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ on:
branches:
- main

jobs:
concurrency:
group: ${{ github.ref_name }}-fossa
cancel-in-progress: true

jobs:
scan:
name: Fossa
runs-on: ubuntu-20.04
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Repository
uses: actions/checkout@v3
- name: Scan
uses: fossas/fossa-action@v1
with:
api-key: ${{ secrets.FOSSA_TOKEN }}
api-key: ${{ secrets.FOSSA_TOKEN }}
64 changes: 64 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Lint

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- '**.md'
types:
- opened
- reopened
- synchronize

defaults:
run:
shell: bash

concurrency:
group: ${{ github.ref_name }}-lint
cancel-in-progress: true

jobs:

lint:
name: Lint
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Golang Environment
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Lint Code
uses: golangci/golangci-lint-action@v3.2.0
with:
args: --timeout 10m0s
only-new-issues: true

njs-lint:
name: NJS Lint
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Run Prettier on NJS code
id: prettier-run
uses: rutajdash/prettier-cli-action@v1.0.0
with:
config_path: ${{ github.workspace }}/internal/nginx/modules/.prettierrc
file_pattern: ${{ github.workspace }}/internal/nginx/modules/**/*.js
prettier_version: 2.6.2
- name: Prettier Output
if: ${{ failure() }}
shell: bash
run: |
echo "The following files are not formatted:"
echo "${{steps.prettier-run.outputs.prettier_output}}"
echo "Run \"make njs-fmt\" locally to format the code"