From 9d60e97ce467c46912dcf7efcefab14e277a5814 Mon Sep 17 00:00:00 2001 From: David Dymko Date: Fri, 18 Apr 2025 19:52:04 -0400 Subject: [PATCH 1/5] ci: add unit test ci --- .github/workflows/golangci-lint.yml | 2 +- .github/workflows/unit-tests.yml | 29 +++++++++++++++++++++++++++++ Makefile | 4 ++-- 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index c54182c..6c07e19 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: stable + go-version-file: go.mod - name: Install Goreleaser uses: goreleaser/goreleaser-action@v6 diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000..9481dc7 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,29 @@ +name: Unit tests + +on: + pull_request: # triggers on every push to a PR + +# Cancel older runs from the same PR/branch +concurrency: + group: pr-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read # checkout needs this + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + # Reads version from go.mod; override with a specific version if you prefer + go-version-file: go.mod + + - name: Run unit tests with the race detector + run: make test-go \ No newline at end of file diff --git a/Makefile b/Makefile index afcca87..f0e0713 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,8 @@ build-all: railcar-build-binaries build-freight railcar-build-binaries: goreleaser release --snapshot --clean --config=./assets/.goreleaser.yaml -.Phony: go-test -go-test: +.Phony: test-go +test-go: go test ./... --race .Phony: lint From 73aad16b1c164659e04ae7eef7bb6a16b6551d98 Mon Sep 17 00:00:00 2001 From: David Dymko Date: Fri, 18 Apr 2025 19:56:07 -0400 Subject: [PATCH 2/5] ci: add makefile to gen asset placeholders --- .github/workflows/unit-tests.yml | 3 +++ Makefile | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 9481dc7..ef047c2 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -25,5 +25,8 @@ jobs: # Reads version from go.mod; override with a specific version if you prefer go-version-file: go.mod + - name: make placeholder assets + run: make asset-placeholders + - name: Run unit tests with the race detector run: make test-go \ No newline at end of file diff --git a/Makefile b/Makefile index f0e0713..ccc8176 100644 --- a/Makefile +++ b/Makefile @@ -15,4 +15,24 @@ test-go: .Phony: lint lint: - golangci-lint run \ No newline at end of file + golangci-lint run + + +.Phony: asset-placeholders +asset-placeholders: + mkdir -p assets/dist/conductor_darwin_amd64_v1 \ + assets/dist/conductor_darwin_arm64_v8.0 \ + assets/dist/conductor_linux_amd64_v1 \ + assets/dist/conductor_linux_arm64_v8.0 \ + assets/dist/conductor_linux_arm_6 \ + assets/dist/conductor_windows_amd64_v1 \ + assets/dist/conductor_windows_arm64_v8.0 \ + assets/dist/conductor_windows_arm_6 + touch assets/dist/conductor_darwin_amd64_v1/conductor \ + assets/dist/conductor_darwin_arm64_v8.0/conductor \ + assets/dist/conductor_linux_amd64_v1/conductor \ + assets/dist/conductor_linux_arm64_v8.0/conductor \ + assets/dist/conductor_linux_arm_6/conductor \ + assets/dist/conductor_windows_amd64_v1/conductor.exe \ + assets/dist/conductor_windows_arm64_v8.0/conductor.exe \ + assets/dist/conductor_windows_arm_6/conductor.exe From 3a7e8ae1881e2b46368eeea4d97e0fbb6e4d4804 Mon Sep 17 00:00:00 2001 From: David Dymko Date: Fri, 18 Apr 2025 19:57:38 -0400 Subject: [PATCH 3/5] ci: newline --- .github/workflows/unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index ef047c2..dd53c7d 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -29,4 +29,4 @@ jobs: run: make asset-placeholders - name: Run unit tests with the race detector - run: make test-go \ No newline at end of file + run: make test-go From 0360399b974f87e2b2b05e65698e4476c636b081 Mon Sep 17 00:00:00 2001 From: David Dymko Date: Fri, 18 Apr 2025 19:59:13 -0400 Subject: [PATCH 4/5] ci: use asset placeholder for lint --- .github/workflows/golangci-lint.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 6c07e19..575e226 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -18,14 +18,8 @@ jobs: with: go-version-file: go.mod - - name: Install Goreleaser - uses: goreleaser/goreleaser-action@v6 - with: - version: "v2.8.2" - install-only: true - - - name: Build railcar binaries - run: make railcar-build-binaries + - name: make placeholder assets + run: make asset-placeholders - name: golangci-lint uses: golangci/golangci-lint-action@v7 From 3cb26aa6b90aaa0f63a25b13b021285a059641f5 Mon Sep 17 00:00:00 2001 From: David Dymko Date: Fri, 18 Apr 2025 19:59:55 -0400 Subject: [PATCH 5/5] ci: remove concurrency check --- .github/workflows/unit-tests.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index dd53c7d..8c5eb1a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -3,11 +3,6 @@ name: Unit tests on: pull_request: # triggers on every push to a PR -# Cancel older runs from the same PR/branch -concurrency: - group: pr-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - permissions: contents: read # checkout needs this