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

refactor: workflows and make targets #5118

Merged
merged 11 commits into from
Oct 21, 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
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
name: check-tests
name: Go Unit Tests
on: pull_request

jobs:
check-tests:
go-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: '1.22'
- run: |
E2E_TEST=true
export E2E_TEST
make test
name: Unit Test
name: Run unit tests for go code in pkg/agent
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: check-shell
name: Lint Shell/Bash Scripts
on: pull_request

jobs:
check-tests:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -11,4 +11,4 @@ jobs:
go-version: '1.22'
- run: |
make validate-shell
name: Verify Shell scripts
name: Lint shell/bash scripts with ShellCheck
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: check-generated
name: Shell/Bash Script Unit Tests
on: pull_request

jobs:
check-generated:
shellspec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: '1.22'
- run: |
make
git diff --exit-code
name: Make generate and diff
make shellspec
name: Run shell/bash script unit tests with shellspec
20 changes: 5 additions & 15 deletions .github/workflows/validate-components.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
name: Validate component manifest
on:
pull_request:
branches:
- master
workflow_dispatch: {}
name: Validate Components
on: pull_request

jobs:
build-and-deploy:
cue:
runs-on: ubuntu-latest
environment: test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: '1.22'
- name: 'install cue'
- name: Install cue
run: |
go version
GOPATH="$(go env | grep GOPATH | cut -d= -f2 | tr -d '"')"
export PATH="$PATH:$GOPATH/bin"
pushd /tmp
GO111MODULE=on go install cuelang.org/go/cmd/cue@latest
popd
- name: 'validate components.json'
run: |
GOPATH="$(go env | grep GOPATH | cut -d= -f2 | tr -d '"')"
export PATH="$PATH:$GOPATH/bin"
cue vet -c ./schemas/manifest.cue
cue eval ./schemas/manifest.cue
- name: 'validate components.json'
- name: Validate components.json conforms to cue schema
run: |
GOPATH="$(go env | grep GOPATH | cut -d= -f2 | tr -d '"')"
export PATH="$PATH:$GOPATH/bin"
Expand Down
30 changes: 18 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ validate-go:
validate-shell:
@./.pipelines/scripts/verify_shell.sh

.PHONY: shellspec
shellspec:
.PHONY: shellspec # TODO: have this run in a container with a stable bash installation
shellspec: bootstrap
@bash ./hack/tools/bin/shellspec

.PHONY: validate-image-version
Expand All @@ -93,18 +93,25 @@ generate-kubelet-flags:
compile-proto-files:
@./hack/tools/bin/buf generate -o . --path ./pkg/proto/ --template ./pkg/proto/buf.gen.yaml

.PHONY: generate
generate: bootstrap
@echo $(GOFLAGS)
.PHONY: generate-manifest
generate-manifest:
./hack/tools/bin/cue export ./schemas/manifest.cue > ./parts/linux/cloud-init/artifacts/manifest.json
@echo "#EOF" >> ./parts/linux/cloud-init/artifacts/manifest.json

.PHONY: generate-testdata
generate-testdata:
@echo $(GOFLAGS)
GENERATE_TEST_DATA="true" go test ./pkg/agent...
@echo "running validate-shell to make sure generated cse scripts are correct"

.PHONY: generate # TODO: ONLY generate go testdata
generate: bootstrap
@echo "Generating go testdata"
@$(MAKE) generate-testdata
@echo "Generating manifest.cue"
@$(MAKE) generate-manifest
@echo "Running validate-shell to make sure generated cse scripts are correct"
@$(MAKE) validate-shell
@echo "Running shellspec tests to validate shell/bash scripts"
@$(MAKE) shellspec
@echo "Validating if components.json conforms to the schema schemas/components.cue."
@echo "Error will be shown if any."
@echo "Validating components.json conforms to the schema schemas/components.cue."
@$(MAKE) validate-components

.PHONY: validate-prefetch
Expand Down Expand Up @@ -173,10 +180,9 @@ endif
ginkgoBuild: generate
make -C ./test/e2e ginkgo-build

test: generate
test:
go test ./...


.PHONY: test-style
test-style: validate-go validate-shell validate-copyright-headers

Expand Down
Loading