Skip to content
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

add new CI step to validate go mod integrity #8

Merged
merged 1 commit into from
Feb 28, 2024
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
38 changes: 26 additions & 12 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,27 @@ name: Golang
on:
pull_request:
branches:
- master
- release-*
- master
- release-*
push:
branches:
- master
- release-*
- master
- release-*

jobs:
check:
validate-go-modules:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- run: make validate-modules
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note: I recently added logic to the device plugin to extract the go version from versions.mk so that these checks can be more consistent. Also added a containerized module validation. It would be good to iterate on something that can be used as standard across our projects.


lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -36,17 +48,19 @@ jobs:
version: latest
args: -v --timeout 5m
skip-cache: true

test:
name: Unit test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- run: make test
- name: Checkout code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- run: make test
build:
runs-on: ubuntu-latest
steps:
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

DOCKER ?= docker
MKDIR ?= mkdir
GO ?= go

include $(CURDIR)/versions.mk

Expand Down Expand Up @@ -78,3 +79,14 @@ PHONY: .shell
-w /work \
--user $$(id -u):$$(id -g) \
$(BUILDIMAGE)

.PHONY: validate-modules
validate-modules:
@echo "- Verifying that the dependencies have expected content..."
$(GO) mod verify
@echo "- Checking for any unused/missing packages in go.mod..."
$(GO) mod tidy
@git diff --exit-code -- go.sum go.mod
@echo "- Checking if the vendor dir is in sync..."
$(GO) mod vendor
@git diff --exit-code -- vendor