Skip to content

Commit 54b7448

Browse files
authored
(Chore): Streamline repo tests (#963)
- Fix snyk test to run in CI - Fix biome snapshots - Fix hadolint snapshots - Fix ansible-lint snapshots and update recommended usage for inverse ignores - Remove windows test workflows - Upgrade the CLI (required fixing some of the above snapshots)
1 parent bb85051 commit 54b7448

33 files changed

Lines changed: 825 additions & 3037 deletions

.github/workflows/nightly.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ jobs:
2828
# This job is used to diagnose plugin config health in advance of a release
2929
linter_tests_main:
3030
name: Plugin Tests Main
31-
# runs-on: [self-hosted, "${{ matrix.os }}"] TODO(Tyler): Set after Windows self-hosted are established.
3231
runs-on: ${{ matrix.os }}
3332
timeout-minutes: 120
3433
strategy:
3534
fail-fast: false
3635
matrix:
3736
linter-version: [Snapshots, Latest]
38-
os: [ubuntu-latest, macOS, windows-latest]
37+
# TODO(Tyler): Re-add Windows runners.
38+
os: [ubuntu-latest, macOS]
3939
steps:
4040
- name: Checkout
4141
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
@@ -213,21 +213,21 @@ jobs:
213213
# Run tool tests only on main
214214
tool_tests_main:
215215
name: Tool Tests Main
216-
# runs-on: [self-hosted, "${{ matrix.os }}"] TODO(Tyler): Set after Windows self-hosted are established.
217216
runs-on: ${{ matrix.os }}
218217
timeout-minutes: 120
219218
strategy:
220219
fail-fast: false
221220
matrix:
222-
os: [ubuntu-latest, macOS, windows-latest]
221+
# TODO(Tyler): Re-add Windows runners.
222+
os: [ubuntu-latest, macOS]
223223
include:
224224
# Normalize the filenames as inputs for ease of parsing
225225
- os: ubuntu-latest
226226
results-file: ubuntu-latest
227227
- os: macOS
228228
results-file: macos-latest
229-
- os: windows-latest
230-
results-file: windows-latest
229+
# - os: windows-latest
230+
# results-file: windows-latest
231231
steps:
232232
- name: Checkout
233233
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

.github/workflows/pr.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,12 @@ jobs:
241241
TRUNK_GITHUB_CHECK_RUN_TITLE: Trunk Check
242242

243243
# Run Windows tests for modified linters and tools
244-
# TODO(Tyler): When this is more stabilized and we want to gate on it, we can make it part of the matrix above.
245244
windows_linter_tests:
246245
name: Windows Linter Tests
247246
runs-on: windows-latest
248247
needs: detect_changes
249-
if: needs.detect_changes.outputs.linters == 'true'
248+
# TODO(Tyler): Re-add Windows runners.
249+
if: needs.detect_changes.outputs.linters == 'true' && false
250250
timeout-minutes: 90
251251
steps:
252252
- name: Checkout
@@ -271,11 +271,12 @@ jobs:
271271
trunk-staging-token: ${{ secrets.TRUNK_DEBUGGER_TOKEN }}
272272
trunk-prod-token: ${{ secrets.TRUNK_ORG_PROD_TOKEN }}
273273

274+
# TODO(Tyler): Re-add Windows runners.
274275
windows_tool_tests:
275276
name: Windows Tool Tests
276277
runs-on: windows-latest
277278
needs: detect_changes
278-
if: needs.detect_changes.outputs.tools == 'true'
279+
if: needs.detect_changes.outputs.tools == 'true' && false
279280
timeout-minutes: 60
280281
steps:
281282
- name: Checkout

.github/workflows/upload_results.reusable.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ jobs:
7676
with:
7777
name: ${{ inputs.results-prefix }}macos-latest-test-results
7878

79-
- name: Retrieve Test Outputs Windows
80-
id: download-windows
81-
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
82-
continue-on-error: true
83-
with:
84-
name: ${{ inputs.results-prefix }}windows-latest-test-results
79+
# TODO(Tyler): Re-add Windows runners.
80+
# - name: Retrieve Test Outputs Windows
81+
# id: download-windows
82+
# uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
83+
# continue-on-error: true
84+
# with:
85+
# name: ${{ inputs.results-prefix }}windows-latest-test-results
8586

8687
- name: Print Test Outputs
8788
continue-on-error: true
@@ -95,15 +96,15 @@ jobs:
9596
cat "macos-latest-res.json" || echo "missing"
9697
echo "::endgroup::"
9798
98-
echo "::group::Windows results"
99-
cat "windows-latest-res.json" || echo "missing"
100-
echo "::endgroup::"
99+
# echo "::group::Windows results"
100+
# cat "windows-latest-res.json" || echo "missing"
101+
# echo "::endgroup::"
101102
102103
- name: Slack Notification For Missing Artifacts
103104
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
104105
if:
105-
steps.download-ubuntu.outcome == 'failure' || steps.download-macos.outcome == 'failure' ||
106-
steps.download-windows.outcome == 'failure'
106+
steps.download-ubuntu.outcome == 'failure' || steps.download-macos.outcome == 'failure'
107+
# || steps.download-windows.outcome == 'failure'
107108
with:
108109
method: chat.postMessage
109110
token: ${{ secrets.TRUNKBOT_SLACK_BOT_TOKEN }}
@@ -114,7 +115,7 @@ jobs:
114115
- type: section
115116
text:
116117
type: mrkdwn
117-
text: "Failure: <https://github.com/trunk-io/plugins/actions/runs/${{ github.run_id }}| Unable to download some ${{ inputs.results-prefix }}test result artifacts (ubuntu: ${{ steps.download-ubuntu.outcome }}, macos: ${{ steps.download-macos.outcome }}, windows: ${{ steps.download-windows.outcome }}) >"
118+
text: "Failure: <https://github.com/trunk-io/plugins/actions/runs/${{ github.run_id }}| Unable to download some ${{ inputs.results-prefix }}test result artifacts (ubuntu: ${{ steps.download-ubuntu.outcome }}, macos: ${{ steps.download-macos.outcome }} >"
118119
119120
- name: Setup Node
120121
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0

linters/ansible-lint/README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,32 @@
22

33
## Usage
44

5-
[Ansible-lint](https://github.com/ansible/ansible-lint) is used to check ansible playbooks. In order
6-
to integrate well with trunk, ansible is usually run using triggers. The trigger system allows file
7-
changes to trigger lint runs. An example of an ansible-lint trigger is included below, but more
8-
information can be found in our [docs](https://docs.trunk.io/check/configuration#trigger-rules).
5+
### New Recommendation
6+
7+
We now recommend using
8+
[inverse ignores](https://docs.trunk.io/code-quality/linters/ignoring-issues-and-files#ignoring-multiple-files)
9+
to run ansible-lint. For backwards compatibility, you will need to specify filetypes yourself and
10+
then a list of ignores.
11+
12+
```yaml
13+
lint:
14+
definitions:
15+
- name: ansible-lint
16+
files: [yaml]
17+
enabled:
18+
- ansible-lint@5.3.2
19+
ignore:
20+
- linters: [ansible-lint]
21+
paths:
22+
- "**"
23+
- "!test_data/jboss-standalone"
24+
```
25+
26+
### Legacy Mode
27+
28+
[Ansible-lint](https://github.com/ansible/ansible-lint) is used to check ansible playbooks.
29+
Historically, in order to integrate well with trunk, you would invoke ansible-lint with
30+
[triggers](https://docs.trunk.io/check/configuration#trigger-rules).
931
1032
```yaml
1133
lint:

linters/ansible-lint/ansible_lint.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ const preCheck =
99
(driver: TrunkLintDriver) => {
1010
const trunkYamlPath = ".trunk/trunk.yaml";
1111
const currentContents = driver.readFile(trunkYamlPath);
12-
const newContents = currentContents.concat(` triggers:
13-
# Run these linters
14-
- linters:
15-
- ansible-lint
16-
# If any files matching these change
12+
const newContents = currentContents.concat(` definitions:
13+
- name: ansible-lint
14+
files: [yaml]
15+
ignore:
16+
- linters: [ansible-lint]
1717
paths:
1818
- "**"
19-
# On this target (A directory in this case)
20-
targets:
21-
- jboss-standalone
19+
- "!jboss-standalone"
2220
`);
2321
driver.writeFile(trunkYamlPath, newContents);
2422

linters/ansible-lint/plugin.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,20 @@ lint:
1919
version: ">=6.1.0"
2020
# sarif support was added in version 6.1.0
2121
output: sarif
22-
run: ansible-lint -f sarif
22+
run: ansible-lint -f sarif ${target}
2323
# ansible-lint >=6.15.0 return exit code 5 when no files matched
2424
success_codes: [0, 2, 5]
25-
run_from: ${target_directory}
25+
run_from: ${parent}
26+
batch: true
2627
- name: lint
2728
version: ">=5.1.3"
2829
# Custom parser type defined in the trunk cli to handle ansible-lint's output.
2930
output: ansible_lint
3031
# parseable-severity was removed after 5.4.0
31-
run: ansible-lint --parseable-severity
32+
run: ansible-lint --parseable-severity ${target}
3233
success_codes: [0, 2]
33-
run_from: ${target_directory}
34+
run_from: ${parent}
35+
batch: true
3436
tools: [ansible-lint]
3537
suggest_if: never
3638
direct_configs: [.ansible-lint]

0 commit comments

Comments
 (0)