Skip to content

Commit 5431426

Browse files
authored
Merge branch 'main' into feature/allow-change-default-branch
2 parents 53d4f49 + b691d8f commit 5431426

File tree

3,469 files changed

+326806
-109317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,469 files changed

+326806
-109317
lines changed

.github/labeler.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Configuration for labeler - https://github.com/actions/labeler
2+
"Type: Breaking change":
3+
- head-branch:
4+
- '^breaking/'
5+
- '^breaking-'
6+
7+
"Type: Feature":
8+
- head-branch:
9+
- '^feat/'
10+
- '^feat-'
11+
- '^feature/'
12+
- '^feature-'
13+
14+
"Type: Bug":
15+
- head-branch:
16+
- '^fix/'
17+
- '^fix-'
18+
- '^bugfix/'
19+
- '^bugfix-'
20+
- '^bug/'
21+
- '^bug-'
22+
23+
"Deprecation":
24+
- head-branch:
25+
- '^deprecate/'
26+
- '^deprecate-'
27+
- '^deprecation/'
28+
- '^deprecation-'
29+
30+
"Type: Maintenance":
31+
- head-branch:
32+
- '^chore/'
33+
- '^chore-'
34+
- '^maintenance/'
35+
- '^maintenance-'
36+
- '^maint/'
37+
- '^maint-'
38+
- '^deps/'
39+
- '^deps-'
40+
- '^dependencies/'
41+
- '^dependencies-'
42+
# - changed-files:
43+
# - any-glob-to-any-file:
44+
# - .github/workflows/**
45+
# - .github/labeler.yml
46+
# - .github/dependabot.yml
47+
# - .github/release.yml
48+
49+
"Type: Documentation":
50+
- head-branch:
51+
- '^docs/'
52+
- '^docs-'
53+
- '^doc/'
54+
- '^doc-'
55+
# - changed-files:
56+
# - any-glob-to-any-file: 'website/**'

.github/workflows/ci.yml

Lines changed: 117 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,134 @@ on:
55
branches: [main]
66
pull_request: {}
77

8+
permissions:
9+
contents: read # for actions/checkout
10+
11+
env:
12+
test_stacks_directory: test_tf_stacks
13+
814
jobs:
915
ci:
16+
name: Continuous Integration
1017
runs-on: ubuntu-latest
1118
env:
12-
GITHUB_TEST_ORGANIZATION: 'kfcampbell-terraform-provider'
19+
GITHUB_TEST_ORGANIZATION: kfcampbell-terraform-provider
1320
steps:
1421
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1522
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
1623
with:
17-
go-version-file: 'go.mod'
24+
go-version-file: go.mod
1825
cache: true
1926
- run: make tools
2027
- run: make lint
2128
- run: make website-lint
2229
- run: make build
2330
- run: make test
31+
32+
generate-matrix:
33+
name: Generate matrix for test stacks
34+
runs-on: ubuntu-latest
35+
outputs:
36+
matrix: ${{ steps.set-matrix.outputs.matrix }}
37+
has-tests: ${{ steps.set-matrix.outputs.has-tests }}
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
41+
42+
- name: Generate matrix
43+
id: set-matrix
44+
run: |
45+
if [ -d "${{ env.test_stacks_directory }}" ]; then
46+
# find all directories and validate their names
47+
VALID_TESTS=()
48+
INVALID_TESTS=()
49+
50+
while IFS= read -r dir; do
51+
dirname=$(basename "$dir")
52+
# validate that directory name only contains alphanumeric, hyphens, underscores, and dots
53+
if [[ "$dirname" =~ ^[a-zA-Z0-9_.-]+$ ]]; then
54+
VALID_TESTS+=("$dirname")
55+
else
56+
INVALID_TESTS+=("$dirname")
57+
fi
58+
done < <(find ${{ env.test_stacks_directory }} -mindepth 1 -maxdepth 1 -type d)
59+
60+
# report invalid directory names if any
61+
if [ ${#INVALID_TESTS[@]} -gt 0 ]; then
62+
echo "::warning::Invalid test directory names found (must contain only alphanumeric, hyphens, underscores, and dots):"
63+
printf ' - %s (will be skipped)\n' "${INVALID_TESTS[@]}"
64+
fi
65+
66+
# create JSON array from valid tests
67+
if [ ${#VALID_TESTS[@]} -gt 0 ]; then
68+
TESTS=$(printf '%s\n' "${VALID_TESTS[@]}" | jq -R -s -c 'split("\n")[:-1]')
69+
echo "matrix=${TESTS}" >> $GITHUB_OUTPUT
70+
echo "has-tests=true" >> $GITHUB_OUTPUT
71+
echo "Found valid test directories: ${TESTS}"
72+
else
73+
echo "matrix=[]" >> $GITHUB_OUTPUT
74+
echo "has-tests=false" >> $GITHUB_OUTPUT
75+
echo "No valid test directories found"
76+
fi
77+
else
78+
echo "Test directory ${{ env.test_stacks_directory }} does not exist"
79+
echo "matrix=[]" >> $GITHUB_OUTPUT
80+
echo "has-tests=false" >> $GITHUB_OUTPUT
81+
fi
82+
83+
tests:
84+
name: Run tests for Terraform test stacks
85+
needs: [ci, generate-matrix]
86+
if: ${{ needs.generate-matrix.outputs.has-tests == 'true' }} # only run if there are some test stacks
87+
runs-on: ubuntu-latest
88+
89+
strategy:
90+
fail-fast: false
91+
matrix:
92+
tests: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
93+
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
97+
98+
- name: Setup Go
99+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
100+
with:
101+
go-version-file: go.mod
102+
cache: true
103+
104+
- name: Build provider
105+
run: go build -o terraform-provider-github
106+
107+
- name: Setup dev overrides
108+
run: |
109+
ROOT_DIR=$(pwd)
110+
cat > ~/.terraformrc << EOF
111+
provider_installation {
112+
dev_overrides {
113+
"integrations/github" = "${ROOT_DIR}"
114+
}
115+
direct {}
116+
}
117+
EOF
118+
119+
- name: Verify dev overrides setup
120+
run: cat ~/.terraformrc
121+
122+
- name: Setup Terraform
123+
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
124+
with:
125+
terraform_version: 1.x
126+
127+
- name: Check Terraform version
128+
run: terraform version
129+
130+
- name: Terraform init
131+
continue-on-error: true # continue even if init fails
132+
run: terraform -chdir=./${{ env.test_stacks_directory }}/${{ matrix.tests }} init
133+
134+
- name: Terraform validate
135+
run: terraform -chdir=./${{ env.test_stacks_directory }}/${{ matrix.tests }} validate
136+
137+
- name: Clean up
138+
run: rm -f ~/.terraformrc terraform-provider-github

.github/workflows/codeql.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
analyze:
14-
name: Analyze
14+
name: Analyze (${{ matrix.language }})
1515
runs-on: ubuntu-latest
1616
permissions:
1717
actions: read
@@ -21,27 +21,36 @@ jobs:
2121
strategy:
2222
fail-fast: false
2323
matrix:
24-
language: [ 'go' ]
24+
include:
25+
- language: actions
26+
build-mode: none
27+
queries: security-extended # can be 'default' (use empty for 'default'), 'security-and-quality', 'security-extended'
28+
- language: go
29+
build-mode: autobuild
30+
queries: '' # will be used 'default' queries
2531

2632
steps:
2733
- name: Checkout repository
2834
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2935

3036
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
37+
if: matrix.language == 'go'
3138
with:
3239
go-version-file: 'go.mod'
3340
cache: true
3441

3542
# Initializes the CodeQL tools for scanning.
3643
- name: Initialize CodeQL
37-
uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
44+
uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
3845
with:
3946
languages: ${{ matrix.language }}
47+
build-mode: ${{ matrix['build-mode'] }}
48+
queries: ${{ matrix.queries }}
4049

4150
- name: Autobuild
42-
uses: github/codeql-action/autobuild@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
51+
uses: github/codeql-action/autobuild@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
4352

4453
- name: Perform CodeQL Analysis
45-
uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
54+
uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
4655
with:
4756
category: "/language:${{matrix.language}}"

.github/workflows/immediate-response.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ on:
1111
- opened
1212
jobs:
1313
respond-to-issue:
14-
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' && github.actor != 'githubactions[bot]' && github.actor != 'octokitbot' }}
14+
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' &&
15+
github.actor != 'githubactions[bot]' && github.actor != 'octokitbot' &&
16+
github.repository == 'integrations/terraform-provider-github' }}
1517
runs-on: ubuntu-latest
1618
steps:
1719
- name: Determine issue or PR number

.github/workflows/labeler.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Pull Request Labeler
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write # Use this if all labels already exist in the repository (i.e., pre-defined in .github/labeler.yml).
10+
11+
jobs:
12+
labeler:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Run Labeler
16+
uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1
17+
with:
18+
sync-labels: false # Whether or not to remove labels when matching files are reverted or no longer changed by the PR

.golangci.yml

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,76 @@
1-
# Visit https://golangci-lint.run/ for usage documentation
2-
# and information on other useful linters
3-
1+
version: "2"
42
run:
5-
deadline: 3m
63
modules-download-mode: vendor
74

8-
issues:
9-
max-per-linter: 0
10-
max-same-issues: 0
11-
125
linters:
13-
disable-all: true
6+
default: none
7+
148
enable:
9+
- copyloopvar
1510
- durationcheck
1611
- errcheck
17-
- exportloopref
18-
# - forcetypeassert
19-
# - godot
20-
- gofmt
21-
- gosimple
12+
- errname
13+
- errorlint
14+
# - forcetypeassert TODO: Re-enable when we can fix the issues
15+
- godot
16+
- govet
2217
- ineffassign
2318
- makezero
2419
- misspell
25-
# - nilerr
26-
# - predeclared
20+
- modernize
21+
- nilerr
22+
- predeclared
2723
- staticcheck
28-
- tenv
2924
- unconvert
30-
# - unparam
25+
- unparam
3126
- unused
32-
- vet
27+
- usetesting
28+
29+
exclusions:
30+
generated: lax
31+
presets:
32+
- comments
33+
- common-false-positives
34+
- legacy
35+
- std-error-handling
36+
paths:
37+
- third_party$
38+
- builtin$
39+
- examples$
40+
rules:
41+
- path: _test\.go
42+
linters:
43+
- unparam
44+
text: always receives
45+
46+
issues:
47+
max-issues-per-linter: 0
48+
max-same-issues: 0
49+
50+
formatters:
51+
enable:
52+
- gofmt
53+
- gofumpt
54+
- goimports
55+
56+
settings:
57+
gofmt:
58+
simplify: true
59+
rewrite-rules:
60+
- pattern: interface{}
61+
replacement: any
62+
- pattern: a[b:len(a)]
63+
replacement: a[b:]
64+
gofumpt:
65+
module-path: github.com/integrations/terraform-provider-github
66+
extra-rules: true
67+
goimports:
68+
local-prefixes:
69+
- github.com/integrations/terraform-provider-github
3370

34-
linters-settings:
35-
errcheck:
36-
ignore: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:ForceNew|Set,fmt:.*,io:Close
71+
exclusions:
72+
generated: lax
73+
paths:
74+
- third_party$
75+
- builtin$
76+
- examples$

0 commit comments

Comments
 (0)