Skip to content
Draft
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
24 changes: 18 additions & 6 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ github.event.pull_request.commits }}

- name: setup go
uses: actions/setup-go@v6
with:
go-version: "1.25.x"
cache: false

- name: validate conventional commit prefix
working-directory: scripts
run: ./validate-conventional-commit-prefix.sh

- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
args: --timeout=5m --color=always --max-same-issues=0 --max-issues-per-linter=0

- name: setup regal
uses: StyraInc/setup-regal@v1
with:
Expand All @@ -46,7 +57,13 @@ jobs:
--format github

validate:
runs-on: ubuntu-latest
strategy:
matrix:
os:
# - 'ubuntu-latest'
# - 'macos-latest'
- 'windows-latest'
runs-on: ${{ matrix.os }}
steps:
- name: checkout source
uses: actions/checkout@v5
Expand All @@ -57,11 +74,6 @@ jobs:
go-version: "1.25.x"
cache: false

- name: golangci-lint
uses: golangci/golangci-lint-action@v8
with:
args: --timeout=5m --color=always --max-same-issues=0 --max-issues-per-linter=0

- name: build
run: make build

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ build: ## Builds Conftest.

.PHONY: test
test: ## Tests Conftest.
@go test -v ./...
@go test ./...

.PHONY: test-examples
test-examples: build ## Runs the tests for the examples.
Expand Down
8 changes: 7 additions & 1 deletion plugin/xdg.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ func (p xdgPath) homeDir(path string) string {
func (p xdgPath) writable(path string) bool {
// The easiest cross-platform way to check if it is writable is
// to just create a directory and then remove it.
tempDir, err := os.MkdirTemp(path, ".conftestcheck-")
tempDir, err := os.MkdirTemp(path, "conftestcheck")
if err != nil {

fmt.Fprintln(os.Stderr, "dir is not writable:", path)

return false
}
os.RemoveAll(tempDir)

fmt.Fprintln(os.Stderr, "dir IS writable:", filepath.Join(path, "conftestcheck"))

return true
}

Expand Down
14 changes: 7 additions & 7 deletions plugin/xdg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestPreferred(t *testing.T) {
t.Parallel()
// t.Parallel()

userHome, err := os.UserHomeDir()
if err != nil {
Expand All @@ -31,31 +31,31 @@ func TestPreferred(t *testing.T) {
{
name: "should return homeDir if no XDG path is set.",
path: pluginsDir,
want: filepath.Join(userHome, conftestDir, pluginsDir),
want: filepath.ToSlash(filepath.Join(userHome, conftestDir, pluginsDir)),
},
{
name: "unwritble XDG_DATA_HOME also returns homeDir",
path: pluginsDir,
xdgDataHome: nonExistant,
want: filepath.Join(userHome, conftestDir, pluginsDir),
want: filepath.ToSlash(filepath.Join(userHome, conftestDir, pluginsDir)),
},
{
name: "should return XDG_DATA_HOME if both XDG_DATA_HOME and XDG_DATA_DIRS is set",
path: pluginsDir,
xdgDataHome: tempDir,
xdgDataDirs: "/tmp2:/tmp3",
want: filepath.Join(tempDir, conftestDir, pluginsDir),
xdgDataDirs: filepath.Join(tempDir, "subdir123"),
want: filepath.ToSlash(filepath.Join(tempDir, conftestDir, pluginsDir)),
},
{
name: "should return first XDG_DATA_DIRS that exists if only XDG_DATA_DIRS is set",
path: pluginsDir,
xdgDataDirs: nonExistant + ":" + tempDir,
want: filepath.Join(tempDir, conftestDir, pluginsDir),
want: filepath.ToSlash(filepath.Join(tempDir, conftestDir, pluginsDir)),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
// t.Parallel()

xdg := xdgPath(conftestDir)
if got := xdg.preferred(tt.path, tt.xdgDataHome, tt.xdgDataDirs); got != tt.want {
Expand Down
Loading