Skip to content

Commit

Permalink
run unit specs in github actions
Browse files Browse the repository at this point in the history
Conditionally skip some user and cert specs on Github Action Windows
workers because the operations under test do not seem to be supported /
possible when running on Github Actions windows workers

The specs in question are skipped when the `GITHUB_ACTIONS` environment
variable is set to `"true"`.

- removed a stray `fmt.Println()` from spec
  • Loading branch information
aramprice committed Dec 27, 2024
1 parent cf6d2d9 commit a68d7d5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
name: go
on:
push:
pull_request:
jobs:
lint:
lint: # <- name
strategy:
matrix:
os: [macos-latest, windows-2019, ubuntu-latest]
name: lint
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -20,3 +20,15 @@ jobs:
if: ${{ matrix.os != 'windows-2019' }}
with:
args: --enable goimports

test-unit: # <- name
strategy:
matrix:
os: [macos-latest, windows-2019, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: go run github.com/onsi/ginkgo/v2/ginkgo run -r --keep-going --skip-package integration
11 changes: 7 additions & 4 deletions platform/cert/cert_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import (
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"

"github.com/cloudfoundry/bosh-agent/v2/platform/cert"
boshdir "github.com/cloudfoundry/bosh-agent/v2/settings/directories"
"github.com/cloudfoundry/bosh-utils/logger"
boshsys "github.com/cloudfoundry/bosh-utils/system"
fakesys "github.com/cloudfoundry/bosh-utils/system/fakes"

"github.com/cloudfoundry/bosh-agent/v2/platform/cert"
boshdir "github.com/cloudfoundry/bosh-agent/v2/settings/directories"
)

const cert1 string = `-----BEGIN CERTIFICATE-----
Expand Down Expand Up @@ -427,6 +428,9 @@ if (Test-Path %[1]s) {
if runtime.GOOS != "windows" {
Skip("Only run on Windows")
}
if os.Getenv("GITHUB_ACTIONS") == "true" {
Skip("`cert.UpdateCertificates()` does not appear to be supported on Github Action windows workers")
}

fs = boshsys.NewOsFileSystem(log)
var err error
Expand All @@ -448,7 +452,6 @@ if (Test-Path %[1]s) {

It("should create the tmpDir if doesn't exist", func() {
_, err := os.Stat(dirProvider.TmpDir())
fmt.Println("BEfore", dirProvider.TmpDir(), err)
missing := os.IsNotExist(err)
Expect(missing).To(BeTrue())
err = certManager.UpdateCertificates(validCerts)
Expand All @@ -462,6 +465,7 @@ if (Test-Path %[1]s) {
err := fs.MkdirAll(dirProvider.TmpDir(), os.FileMode(0777))
Expect(err).To(BeNil())
})

It("adds certs to the trusted cert chain", func() {
err := certManager.UpdateCertificates(validCerts)
Expect(err).To(BeNil())
Expand Down Expand Up @@ -494,7 +498,6 @@ if (Test-Path %[1]s) {
Eventually(session.Out).Should(gbytes.Say("0"))
})
})

})
})
})
Expand Down
4 changes: 4 additions & 0 deletions platform/windows_platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,10 @@ var _ = Describe("BOSH User Commands", func() {
})

It("can delete a user, and any files in the user home directory which aren't in use by the registry", func() {
if os.Getenv("GITHUB_ACTIONS") == "true" {
Skip("User deletion does not appear to be supported on Github Action windows workers")
}

Expect(platform.CreateUser(testUsername, "")).To(Succeed())
Expect(userExists(testUsername)).To(Succeed())

Expand Down

0 comments on commit a68d7d5

Please sign in to comment.