Skip to content

Commit ffb3fe5

Browse files
authored
Merge pull request #818 from kolyshkin/ci-update
ci: fix lint, bump and pin actions, add dependabot
2 parents 8a4db57 + d64607d commit ffb3fe5

4 files changed

Lines changed: 66 additions & 24 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Please see the documentation for all configuration options:
2+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
3+
4+
version: 2
5+
updates:
6+
# Dependencies listed in .github/workflows/*.yml
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
11+
cooldown:
12+
default-days: 7

‎.github/workflows/test.yml‎

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,66 @@ on:
88
- release-*
99
pull_request:
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215

1316
lint:
14-
runs-on: ubuntu-24.04
17+
runs-on: ubuntu-26.04
1518
steps:
16-
- uses: actions/setup-go@v6
19+
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
1720
with:
1821
go-version: stable
19-
- uses: actions/checkout@v5
20-
- uses: golangci/golangci-lint-action@v9
22+
cache: false
23+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
24+
with:
25+
persist-credentials: false
26+
- uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
2127
with:
22-
version: v2.9
28+
version: latest
2329

2430
commit:
25-
runs-on: ubuntu-24.04
31+
permissions:
32+
contents: read
33+
pull-requests: read # Needed to list the PR's commits.
34+
runs-on: ubuntu-26.04
2635
# Only check commits on pull requests.
2736
if: github.event_name == 'pull_request'
2837
steps:
29-
- name: get pr commits
30-
id: 'get-pr-commits'
31-
uses: tim-actions/get-pr-commits@v1.3.1
32-
with:
33-
token: ${{ secrets.GITHUB_TOKEN }}
38+
- name: check commit subject line length
39+
env:
40+
GH_TOKEN: ${{ github.token }}
41+
PR_NUMBER: ${{ github.event.pull_request.number }}
42+
run: |
43+
# Save to a file first, so that a gh failure fails the step (rather
44+
# than being masked by jq succeeding on empty input).
45+
gh api --paginate --slurp \
46+
"/repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/commits" \
47+
> "$RUNNER_TEMP/commits.json"
3448
35-
- name: check subject line length
36-
uses: tim-actions/commit-message-checker-with-regex@v0.3.2
37-
with:
38-
commits: ${{ steps.get-pr-commits.outputs.commits }}
39-
pattern: '^.{0,72}(\n.*)*$'
40-
error: 'Subject too long (max 72)'
49+
# A page is an array, and --slurp gives an array of pages, thus
50+
# the double iteration. Merge commits are skipped.
51+
long=$(jq -r '
52+
.[][]
53+
| select(.parents | length <= 1)
54+
| (.commit.message | split("\n")[0]) as $subject
55+
| select(($subject | length) > 72)
56+
| "\(.sha[0:12]) \($subject)"
57+
' "$RUNNER_TEMP/commits.json")
58+
59+
if [ -z "$long" ]; then
60+
echo "All commit subject lines are 72 characters or less."
61+
exit 0
62+
fi
63+
64+
while read -r commit; do
65+
echo "::error::subject line too long (max 72 characters): $commit"
66+
done <<<"$long"
67+
exit 1
4168
4269
test:
43-
runs-on: ubuntu-24.04
70+
runs-on: ubuntu-26.04
4471
strategy:
4572
fail-fast: false
4673
matrix:
@@ -49,11 +76,14 @@ jobs:
4976

5077
steps:
5178
- name: checkout
52-
uses: actions/checkout@v5
79+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
80+
with:
81+
persist-credentials: false
5382
- name: install go ${{ matrix.go-version }}
54-
uses: actions/setup-go@v6
83+
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
5584
with:
5685
go-version: ${{ matrix.go-version }}
86+
cache: false
5787
- name: build
5888
run: make EXTRA_FLAGS="${{ matrix.race }}"
5989
- name: test

‎validate/validate.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,13 +742,13 @@ func isStruct(t reflect.Type) bool {
742742
}
743743

744744
func isStructPtr(t reflect.Type) bool {
745-
return t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct
745+
return t.Kind() == reflect.Pointer && t.Elem().Kind() == reflect.Struct
746746
}
747747

748748
func checkMandatoryUnit(field reflect.Value, tagField reflect.StructField, parent string) (errs error) {
749749
mandatory := !strings.Contains(tagField.Tag.Get("json"), "omitempty")
750750
switch field.Kind() {
751-
case reflect.Ptr:
751+
case reflect.Pointer:
752752
if mandatory && field.IsNil() {
753753
errs = multierror.Append(errs, fmt.Errorf("'%s.%s' should not be empty", parent, tagField.Name))
754754
}

‎validate/validate_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ func TestCheckHooks(t *testing.T) {
669669
val: rspec.Spec{
670670
Version: "1.0.0",
671671
Hooks: &rspec.Hooks{
672-
Prestart: []rspec.Hook{
672+
Prestart: []rspec.Hook{ //nolint:staticcheck // Ignore SA1019: rspec.Hooks.Prestart is deprecated
673673
{
674674
Path: "/usr/bin/fix-mounts",
675675
},
@@ -682,7 +682,7 @@ func TestCheckHooks(t *testing.T) {
682682
val: rspec.Spec{
683683
Version: "1.0.0",
684684
Hooks: &rspec.Hooks{
685-
Prestart: []rspec.Hook{
685+
Prestart: []rspec.Hook{ //nolint:staticcheck // Ignore SA1019: rspec.Hooks.Prestart is deprecated
686686
{
687687
Path: "usr",
688688
},

0 commit comments

Comments
 (0)