-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (130 loc) · 3.63 KB
/
Copy pathci.yml
File metadata and controls
139 lines (130 loc) · 3.63 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
shellcheck:
name: ShellCheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
env:
SHELLCHECK_OPTS: -e SC1091 -x
with:
severity: error
scandir: '.'
ignore_paths: >-
.git
.github
python:
name: Python (compile + ruff)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Discover python files
id: pyfiles
run: |
mapfile -t files < <(git ls-files '*.py')
printf '%s\n' "${files[@]}"
{
echo 'files<<EOF'
printf '%s\n' "${files[@]}"
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Byte-compile
if: steps.pyfiles.outputs.files != ''
run: |
while IFS= read -r f; do
[ -z "$f" ] && continue
python -m py_compile "$f"
done <<< "${{ steps.pyfiles.outputs.files }}"
- name: Install ruff
run: pip install ruff==0.6.9
- name: Lint with ruff
run: ruff check --output-format=github .
go:
name: Go (cloudflare-ip-logger)
runs-on: ubuntu-latest
defaults:
run:
working-directory: cloudflare-ip-logger
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v7
with:
go-version-file: cloudflare-ip-logger/go.mod
cache-dependency-path: cloudflare-ip-logger/go.sum
- name: Install SQLite headers
run: sudo apt-get update && sudo apt-get install -y libsqlite3-dev
- name: go mod download
run: go mod download
- name: go vet
run: go vet ./...
- name: Check formatting
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "::error::Files not gofmt-formatted:"
echo "$unformatted"
exit 1
fi
- name: go build
env:
CGO_ENABLED: '1'
run: |
go build -ldflags="-s -w" -o cf-ip-logger .
go build -o cf-log-parser ./cmd/logparser
- name: go test
run: go test ./...
hadolint:
name: Hadolint (Dockerfile)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: hadolint/hadolint-action@v3.4.0
with:
dockerfile: cloudflare-ip-logger/Dockerfile
config: cloudflare-ip-logger/.hadolint.yaml
failure-threshold: warning
docker-build:
name: Docker build (cf-ip-logger)
runs-on: ubuntu-latest
needs: [go, hadolint]
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- name: Build image (no push)
uses: docker/build-push-action@v7
with:
context: cloudflare-ip-logger
push: false
load: true
tags: cf-ip-logger:ci
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Smoke-test image
run: |
docker run --rm --entrypoint sh cf-ip-logger:ci -c 'test -x /app/cf-ip-logger && echo OK'
yaml:
name: YAML lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- run: pip install yamllint==1.35.1
- run: yamllint -c .yamllint.yml .