generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 23
99 lines (84 loc) · 2.89 KB
/
pr-code-checks.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
name: PR Code Checks
on:
pull_request:
branches:
- "main"
- "release-*"
workflow_dispatch:
env:
GITLEAKS_VERSION: 8.18.2
jobs:
# This is a workaround to bypass the limitations of the workflow path filter:
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
check-changed-files:
outputs:
check: ${{ steps.changed-files.outputs.any_modified }}
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.draft == false }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Get changed files
uses: tj-actions/changed-files@6b2903bdce6310cfbddd87c418f253cf29b2dec9
id: changed-files
with:
files_ignore: |
docs/**
**/*.md
OWNERS
CODEOWNERS
- name: List changed files
run: echo '${{ steps.changed-files.outputs.all_changed_files }}' >> $GITHUB_STEP_SUMMARY
unit-tests:
runs-on: ubuntu-latest
needs:
- check-changed-files
if: ${{ needs.check-changed-files.outputs.check == 'true' }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Golang
uses: "./.github/template/setup-golang"
- name: Run tests
run: make test
lint:
runs-on: ubuntu-latest
needs:
- check-changed-files
if: ${{ needs.check-changed-files.outputs.check == 'true' }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Golang
uses: "./.github/template/setup-golang"
- name: Run lint
run: make lint
coverage:
runs-on: ubuntu-latest
needs:
- check-changed-files
if: ${{ needs.check-changed-files.outputs.check == 'true' }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Golang
uses: "./.github/template/setup-golang"
- name: Run coverage check
run: make check-coverage
gitleaks:
runs-on: ubuntu-latest
needs:
- check-changed-files
if: ${{ needs.check-changed-files.outputs.check == 'true' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch gitleaks ${{ env.GITLEAKS_VERSION }}
run: curl -Lso gitleaks.tar.gz https://github.com/gitleaks/gitleaks/releases/download/v${{ env.GITLEAKS_VERSION }}/gitleaks_${{ env.GITLEAKS_VERSION }}_linux_x64.tar.gz && tar -xvzf ./gitleaks.tar.gz
- name: Run gitleaks
# Scan commits between base and head of the pull request
run: ./gitleaks detect --log-opts=${PULL_BASE_SHA}...${PULL_HEAD_SHA} --verbose --redact
env:
PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PULL_HEAD_SHA: ${{ github.event.pull_request.head.sha }}