-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (145 loc) · 5.32 KB
/
lint.yml
File metadata and controls
172 lines (145 loc) · 5.32 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Lint
on:
push:
branches: [main]
pull_request:
schedule:
# Weekly full link sweep on Sunday 06:00 UTC. Pull-requests still run
# link-check in modified-only mode so they stay fast.
- cron: '0 6 * * 0'
permissions:
contents: read
concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true
jobs:
shellcheck:
name: shellcheck + bash -n
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install shellcheck
run: |
sudo apt-get update -qq
sudo apt-get install -y shellcheck
- name: bash -n syntax pre-check on every .sh
run: |
set -e
# Syntax-check every tracked shell script, including extensionless
# helpers in bin/.
# Fails fast so the more expensive shellcheck only runs if
# the scripts parse at all.
while IFS= read -r -d '' f; do
echo "bash -n $f"
bash -n "$f"
done < <(
for f in $(git ls-files); do
[ -f "$f" ] || continue
case "$f" in
*.sh) printf '%s\0' "$f" ;;
*) head -n 1 "$f" | grep -Eq '^#!.*(ba)?sh' && printf '%s\0' "$f" || true ;;
esac
done
)
- name: shellcheck (warning severity)
run: |
# SC1090 (can't follow non-constant source), SC2034 (unused var
# exported for sibling scripts), SC2155 (declare and assign on
# one line) are noisy in this codebase and intentional.
mapfile -d '' shell_files < <(
for f in $(git ls-files); do
[ -f "$f" ] || continue
case "$f" in
*.sh) printf '%s\0' "$f" ;;
*) head -n 1 "$f" | grep -Eq '^#!.*(ba)?sh' && printf '%s\0' "$f" || true ;;
esac
done
)
shellcheck -S warning \
-e SC1090,SC2034,SC2155 \
"${shell_files[@]}"
rust:
name: rust fmt + clippy + unit tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Install build dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y libwayland-dev libx11-dev libdbus-1-dev pkg-config libcairo2-dev libglib2.0-dev libpango1.0-dev
- name: Cache cargo registry + target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rs/target
key: ${{ runner.os }}-cargo-${{ hashFiles('rs/Cargo.lock', 'rs/Cargo.toml', 'rs/**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: cargo fmt
run: cargo fmt --manifest-path rs/Cargo.toml --all --check
- name: cargo clippy
run: cargo clippy --release --locked --manifest-path rs/Cargo.toml -- -D warnings
- name: cargo clippy overlay wayland
run: cargo clippy --release --locked --manifest-path rs/Cargo.toml -p flashpaste-overlayd --features wayland -- -D warnings
- name: cargo unit tests
run: cargo test --locked --manifest-path rs/Cargo.toml --workspace --lib --bins
package-smoke:
name: package smoke
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install package build dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y dpkg-dev libwayland-dev libx11-dev libdbus-1-dev pkg-config libcairo2-dev libglib2.0-dev libpango1.0-dev
- name: Cache cargo registry + target
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rs/target
key: ${{ runner.os }}-cargo-${{ hashFiles('rs/Cargo.lock', 'rs/Cargo.toml', 'rs/**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build Rust workspace
run: cargo build --release --locked --manifest-path rs/Cargo.toml
- name: Build overlay daemon
run: cargo build --release --locked --manifest-path rs/Cargo.toml -p flashpaste-overlayd --features wayland
- name: Build .deb
run: VERSION=0.0.0 bash packaging/build-deb.sh
- name: Install package in Ubuntu container
run: bash packaging/package-smoke.sh
markdown-lint:
name: markdownlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run markdownlint-cli2
uses: DavidAnson/markdownlint-cli2-action@v18
with:
globs: '**/*.md'
config: '.markdownlint.json'
link-check:
name: markdown link-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check links in markdown
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'no'
config-file: '.github/markdown-link-check-config.json'
# Full sweep on push/schedule, modified-only on pull requests so
# PR feedback stays fast.
check-modified-files-only: ${{ github.event_name == 'pull_request' && 'yes' || 'no' }}
base-branch: 'main'