Skip to content

Commit 5c376b8

Browse files
authored
Merge branch 'main' into dependabot/github_actions/actions/download-artifact-7
2 parents 26b3b3a + 174fd27 commit 5c376b8

File tree

6 files changed

+56
-32
lines changed

6 files changed

+56
-32
lines changed

Makefile

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ SHELL := bash
1616
TOPDIR := $(shell git rev-parse --show-toplevel)
1717
TMPDIR := $(TOPDIR)/tmp
1818
HUGO_BIN := $(TMPDIR)/hugo/hugo
19-
PY_FILES := $(shell find . -type f -name "*.py" -not -path "./worktrees/*" -not -path "*/.venv/*" -print)
20-
SH_FILES := $(shell find hack/ -type f -name "*.sh" -not -path "./worktrees/*" -not -path "*/.venv/*" -print)
21-
YAML_FILES := $(shell find . -type f \( -name "*.yml" -o -name "*.yaml" \) -not -path "./.vale/*" -not -path "./docs/themes/hugo-book/.github/*" -not -path "./worktrees/*" -not -path "./vendor/*" -print)
22-
MD_FILES := $(shell find . -type f -name "*.md" -not -path "./tmp/*" -not -path "./vendor/*" -not -path "*/.venv/*" -not -path "./.vale/*" -not -path "./docs/themes/*" -not -path "./.git/*" -not -path "./worktrees/*" -print)
19+
20+
# Safe file list helpers using null-delimited output
21+
# Usage: $(call GIT_LS_FILES,<patterns>,<command>)
22+
GIT_LS_FILES = git ls-files -z -- $(1) | xargs -0 -r $(2)
23+
PY_PATTERNS := '*.py' ':!vendor/*'
24+
SH_PATTERNS := 'hack/*.sh' ':!vendor/*'
25+
YAML_PATTERNS := '*.yml' '*.yaml' ':!.vale/*' ':!docs/themes/*' ':!vendor/*'
26+
MD_PATTERNS := '*.md' ':!docs/themes/*' ':!.vale/*' ':!vendor/*'
27+
MD_YAML_PATTERNS := '*.md' '*.yml' '*.yaml' ':!docs/themes/*' ':!.vale/*' ':!vendor/*' ':!tmp/*'
2328

2429
ifeq ($(PAC_VERSION),)
2530
PAC_VERSION="$(shell git describe --tags --exact-match 2>/dev/null || echo nightly-`date +'%Y%m%d'`-`git rev-parse --short HEAD`)"
@@ -89,30 +94,30 @@ lint-go: ## runs go linter on all go files
8994
--timeout $(TIMEOUT_UNIT)
9095

9196
.PHONY: lint-yaml
92-
lint-yaml: ${YAML_FILES} ## runs yamllint on all yaml files
97+
lint-yaml: ## runs yamllint on all yaml files
9398
@echo "Linting yaml files..."
94-
@yamllint -c .yamllint $(YAML_FILES)
99+
@$(call GIT_LS_FILES,$(YAML_PATTERNS),yamllint -c .yamllint) || true
95100

96101

97102
.PHONY: lint-md
98103
lint-md: ## runs markdownlint and vale on all markdown files
99104
@echo "Linting markdown files..."
100-
@markdownlint $(MD_FILES)
105+
@$(call GIT_LS_FILES,$(MD_PATTERNS),markdownlint) || true
101106
@echo "Grammar check with vale of documentation..."
102107
@vale docs/content --output=line --glob='*.md'
103108
@echo "CodeSpell on docs content"
104109
@codespell docs/content
105110

106111
.PHONY: lint-python
107-
lint-python: ${PY_FILES} ## runs pylint on all python files
112+
lint-python: ## runs pylint on all python files
108113
@echo "Linting python files..."
109-
@ruff check $(PY_FILES)
110-
@ruff format --check $(PY_FILES)
114+
@$(call GIT_LS_FILES,$(PY_PATTERNS),ruff check) || true
115+
@$(call GIT_LS_FILES,$(PY_PATTERNS),ruff format --check) || true
111116

112117
.PHONY: lint-shell
113-
lint-shell: ${SH_FILES} ## runs shellcheck on all python files
118+
lint-shell: ## runs shellcheck on all shell files
114119
@echo "Linting shell script files..."
115-
@shellcheck $(SH_FILES)
120+
@$(call GIT_LS_FILES,$(SH_PATTERNS),shellcheck) || true
116121

117122
.PHONY: gitlint
118123
gitlint: ## Run gitlint
@@ -129,19 +134,21 @@ fix-linters: fix-golangci-lint fix-python-errors fix-markdownlint fix-trailing-s
129134
.PHONY: fix-markdownlint
130135
fix-markdownlint: ## run markdownlint and fix on all markdown file
131136
@echo "Fixing markdown files..."
132-
@markdownlint --fix $(MD_FILES)
137+
@$(call GIT_LS_FILES,$(MD_PATTERNS),markdownlint --fix) || true
133138

134139
.PHONY: fix-trailing-spaces
135140
fix-trailing-spaces: ## remove trailing spaces on all markdown and yaml file
136-
@sed --in-place 's/[[:space:]]\+$$//' $(MD_FILES) $(YAML_FILES)
137-
@[[ -n `git status --porcelain $(MD_FILES) $(YAML_FILES)` ]] && { echo "Markdowns and Yaml files has been cleaned 🧹. Cleaned Files: ";git status --porcelain $(MD_FILES) $(YAML_FILES) ;} || echo "Markdown and YAML are clean ✨"
141+
@$(call GIT_LS_FILES,$(MD_YAML_PATTERNS),sed --in-place 's/[[:space:]]\+$$//' --) || true
142+
@STATUS=$$(git status --porcelain -- $$(git ls-files -- $(MD_YAML_PATTERNS))) && \
143+
[[ -n "$$STATUS" ]] && { echo "Markdowns and Yaml files has been cleaned 🧹. Cleaned Files: "; echo "$$STATUS" ;} || echo "Markdown and YAML are clean ✨"
138144

139-
.PHONE: fix-python-errors
145+
.PHONY: fix-python-errors
140146
fix-python-errors: ## fix all python errors generated by ruff
141147
@echo "Fixing python files..."
142-
@ruff check --fix $(PY_FILES)
143-
@ruff format $(PY_FILES)
144-
@[[ -n `git status --porcelain $(PY_FILES)` ]] && { echo "Python files has been cleaned 🧹. Cleaned Files: ";git status --porcelain $(PY_FILES) ;} || echo "Python files are clean ✨"
148+
@$(call GIT_LS_FILES,$(PY_PATTERNS),ruff check --fix) || true
149+
@$(call GIT_LS_FILES,$(PY_PATTERNS),ruff format) || true
150+
@STATUS=$$(git status --porcelain -- $$(git ls-files -- $(PY_PATTERNS))) && \
151+
[[ -n "$$STATUS" ]] && { echo "Python files has been cleaned 🧹. Cleaned Files: "; echo "$$STATUS" ;} || echo "Python files are clean ✨"
145152

146153
.PHONY: fix-golangci-lint
147154
fix-golangci-lint: ## run golangci-lint and fix on all go files
@@ -201,5 +208,3 @@ dev-docs: download-hugo ## preview live your docs with hugo
201208
.PHONY: clean
202209
clean: ## clean build artifacts
203210
rm -fR bin
204-
205-

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ require (
5050
cel.dev/expr v0.25.1 // indirect
5151
github.com/42wim/httpsig v1.2.3 // indirect
5252
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect
53-
github.com/cert-manager/cert-manager v1.19.2 // indirect
53+
github.com/cert-manager/cert-manager v1.19.3 // indirect
5454
github.com/cloudevents/sdk-go/sql/v2 v2.16.2 // indirect
5555
github.com/coreos/go-oidc/v3 v3.17.0 // indirect
5656
github.com/fxamacker/cbor/v2 v2.9.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ github.com/bradleyfalzon/ghinstallation/v2 v2.17.0/go.mod h1:vuD/xvJT9Y+ZVZRv4HQ
7979
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
8080
github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g=
8181
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
82-
github.com/cert-manager/cert-manager v1.19.2 h1:jSprN1h5pgNDSl7HClAmIzXuTxic/5FXJ32kbQHqjlM=
83-
github.com/cert-manager/cert-manager v1.19.2/go.mod h1:e9NzLtOKxTw7y99qLyWGmPo6mrC1Nh0EKKcMkRfK+GE=
82+
github.com/cert-manager/cert-manager v1.19.3 h1:3d0Nk/HO3BOmAdBJNaBh+6YgaO3Ciey3xCpOjiX5Obs=
83+
github.com/cert-manager/cert-manager v1.19.3/go.mod h1:e9NzLtOKxTw7y99qLyWGmPo6mrC1Nh0EKKcMkRfK+GE=
8484
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
8585
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
8686
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=

pkg/reconciler/finalizer_test.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package reconciler
22

33
import (
4-
"strings"
4+
"fmt"
5+
"net/http"
56
"testing"
67

78
"github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode/keys"
@@ -13,6 +14,7 @@ import (
1314
"github.com/openshift-pipelines/pipelines-as-code/pkg/params/info"
1415
"github.com/openshift-pipelines/pipelines-as-code/pkg/sync"
1516
testclient "github.com/openshift-pipelines/pipelines-as-code/pkg/test/clients"
17+
ghtesthelper "github.com/openshift-pipelines/pipelines-as-code/pkg/test/github"
1618
testkubernetestint "github.com/openshift-pipelines/pipelines-as-code/pkg/test/kubernetestint"
1719
tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
1820
"go.uber.org/zap"
@@ -31,7 +33,7 @@ var (
3133
Namespace: "pac-app-pipelines",
3234
},
3335
Spec: v1alpha1.RepositorySpec{
34-
URL: "https://github.com/sm43/pac-app",
36+
URL: "https://github.com/org/repo",
3537
ConcurrencyLimit: &concurrency,
3638
GitProvider: &v1alpha1.GitProvider{
3739
Secret: &v1alpha1.Secret{
@@ -56,8 +58,8 @@ func getTestPR(name, state string) *tektonv1.PipelineRun {
5658
keys.Repository: finalizeTestRepo.Name,
5759
keys.GitProvider: "github",
5860
keys.SHA: "123afc",
59-
keys.URLOrg: "sm43",
60-
keys.URLRepository: "pac-app",
61+
keys.URLOrg: "org",
62+
keys.URLRepository: "repo",
6163
},
6264
},
6365
Spec: tektonv1.PipelineRunSpec{
@@ -70,6 +72,16 @@ func TestReconciler_FinalizeKind(t *testing.T) {
7072
observer, _ := zapobserver.New(zap.InfoLevel)
7173
fakelogger := zap.New(observer).Sugar()
7274

75+
_, mux, mockServerURL, teardown := ghtesthelper.SetupGH()
76+
defer teardown()
77+
78+
finalizeTestRepo.Spec.GitProvider.URL = mockServerURL
79+
80+
// Mock status endpoint
81+
mux.HandleFunc("/repos/org/repo/statuses/123afc", func(rw http.ResponseWriter, _ *http.Request) {
82+
fmt.Fprint(rw, `{"state":"pending"}`)
83+
})
84+
7385
tests := []struct {
7486
name string
7587
pipelinerun *tektonv1.PipelineRun
@@ -159,9 +171,7 @@ func TestReconciler_FinalizeKind(t *testing.T) {
159171
}
160172
}
161173
err := r.FinalizeKind(ctx, tt.pipelinerun)
162-
if err != nil && !strings.Contains(err.Error(), "401 Bad credentials []") {
163-
t.Fatalf("expected no error, got %v", err)
164-
}
174+
assert.NilError(t, err)
165175

166176
// if repo was deleted then no queue will be there
167177
if tt.skipAddingRepo {

pkg/reconciler/reconciler_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@ func TestReconcileKind_SCMReportingLogic(t *testing.T) {
318318
observer, _ := zapobserver.New(zap.InfoLevel)
319319
logger := zap.New(observer).Sugar()
320320

321+
_, mux, ghTestServerURL, teardown := ghtesthelper.SetupGH()
322+
defer teardown()
323+
324+
// Mock status endpoint
325+
mux.HandleFunc("/repos/random/app/statuses/123afc", func(rw http.ResponseWriter, _ *http.Request) {
326+
fmt.Fprint(rw, `{"state":"pending"}`)
327+
})
328+
321329
tests := []struct {
322330
name string
323331
pipelineRun *tektonv1.PipelineRun
@@ -434,6 +442,7 @@ func TestReconcileKind_SCMReportingLogic(t *testing.T) {
434442
Spec: v1alpha1.RepositorySpec{
435443
URL: randomURL,
436444
GitProvider: &v1alpha1.GitProvider{
445+
URL: ghTestServerURL,
437446
Secret: &v1alpha1.Secret{
438447
Name: "pac-git-basic-auth-owner-repo",
439448
},

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ github.com/census-instrumentation/opencensus-proto/gen-go/agent/trace/v1
5353
github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1
5454
github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1
5555
github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1
56-
# github.com/cert-manager/cert-manager v1.19.2
56+
# github.com/cert-manager/cert-manager v1.19.3
5757
## explicit; go 1.25.0
5858
github.com/cert-manager/cert-manager/pkg/apis/acme
5959
github.com/cert-manager/cert-manager/pkg/apis/acme/v1

0 commit comments

Comments
 (0)