Skip to content

Commit b9020e8

Browse files
authored
Introduce --snyk-args and --hook-args arguments (#50)
### Description Refactor and rebuild entire logic of the application. This introduces breaking change on how to pass `snyk` arguments into the hook. More details in `README.md`.
1 parent f28541d commit b9020e8

48 files changed

Lines changed: 1291 additions & 346 deletions

Some content is hidden

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

.bpkg.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fabasoad/sh-logging
2+
fabasoad/sh-validators
Lines changed: 12 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,25 @@
11
---
22
name: Functional Tests
33

4-
on: # yamllint disable-line rule:truthy
5-
pull_request: {}
6-
push:
7-
branches:
8-
- "main"
4+
on:
5+
pull_request:
6+
paths:
7+
- .github/workflows/functional-tests.yml
8+
- src/**
9+
- tests/**
10+
- .bpkg.lock
911

1012
defaults:
1113
run:
1214
shell: sh
1315

1416
jobs:
15-
package-manager:
16-
name: Package manager
17-
timeout-minutes: 5
18-
strategy:
19-
fail-fast: false
20-
matrix:
21-
os: ["macos", "ubuntu", "windows"]
22-
type: ["npm", "yarn", "brew", "scoop"]
23-
exclude:
24-
- os: ubuntu
25-
type: brew
26-
- os: windows
27-
type: brew
28-
- os: ubuntu
29-
type: scoop
30-
- os: macos
31-
type: scoop
32-
runs-on: ${{ matrix.os }}-latest
33-
steps:
34-
- name: Checkout ${{ github.repository }}
35-
uses: actions/checkout@v4
36-
- name: Setup scoop
37-
if: ${{ matrix.type == 'scoop' }}
38-
uses: MinoruSekine/setup-scoop@v4
39-
- name: Configure yarn
40-
if: ${{ runner.os == 'Windows' && matrix.type == 'yarn' }}
41-
run: yarn global bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
42-
shell: pwsh
43-
- name: Install snyk
44-
run: ./hooks/installation/install-${{ matrix.type }}.sh
45-
- name: Print version
46-
run: snyk --version
47-
standalone:
48-
name: Standalone
49-
timeout-minutes: 5
50-
strategy:
51-
fail-fast: false
52-
matrix:
53-
os: ["macos", "ubuntu", "windows"]
54-
runs-on: ${{ matrix.os }}-latest
55-
steps:
56-
- name: Checkout ${{ github.repository }}
57-
uses: actions/checkout@v4
58-
- name: Install snyk
59-
run: ./hooks/installation/install-standalone.sh
60-
- name: Print version
61-
run: snyk --version
62-
standalone-alpine:
63-
name: Standalone
64-
timeout-minutes: 5
65-
strategy:
66-
fail-fast: false
67-
matrix:
68-
image: ["alpine"]
17+
functional-tests-all:
18+
name: All
6919
runs-on: ubuntu-latest
70-
container:
71-
image: ${{ matrix.image }}:latest
20+
timeout-minutes: 5
7221
steps:
7322
- name: Checkout ${{ github.repository }}
7423
uses: actions/checkout@v4
75-
- name: Install tools
76-
run: apk add curl
77-
- name: Install snyk
78-
run: ./hooks/installation/install-standalone.sh
79-
- name: Print version
80-
run: snyk --version
24+
- name: Run tests
25+
run: make test

.github/workflows/linting.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ jobs:
1111
pre-commit:
1212
name: Pre-commit
1313
uses: fabasoad/reusable-workflows/.github/workflows/wf-pre-commit.yml@main
14+
with:
15+
skip-hooks: "build, test"

.markdownlint.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
default: true
3+
MD013:
4+
code_blocks: false
5+
tables: false
6+
MD041: false

.pre-commit-config.yaml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@ default_install_hook_types: ["pre-commit", "pre-push"]
33
default_stages: ["commit", "push"]
44
minimum_pre_commit_version: 2.18.0
55
repos:
6+
- repo: local
7+
hooks:
8+
- id: build
9+
name: Build
10+
entry: make build
11+
language: system
12+
pass_filenames: false
13+
verbose: true
14+
stages: ["push"]
15+
- id: test
16+
name: Functional tests
17+
entry: make test
18+
language: system
19+
pass_filenames: false
20+
verbose: true
21+
stages: ["push"]
22+
- id: prettier
23+
name: Prettier
24+
entry: prettier --write --ignore-unknown
25+
language: node
26+
types: [text]
27+
args: []
28+
# https://github.com/prettier/prettier/releases
29+
additional_dependencies: ["prettier@3.3.3"]
30+
stages: ["commit"]
631
# Security
732
- repo: https://github.com/Yelp/detect-secrets
833
rev: v1.5.0
@@ -47,11 +72,6 @@ repos:
4772
args: ["-pyflakes="]
4873
stages: ["commit"]
4974
# Other
50-
- repo: https://github.com/pre-commit/mirrors-prettier
51-
rev: v3.1.0
52-
hooks:
53-
- id: prettier
54-
stages: ["commit"]
5575
- repo: https://github.com/pre-commit/pre-commit-hooks
5676
rev: v4.6.0
5777
hooks:

.pre-commit-hooks.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
---
2+
- id: snyk-code
3+
name: Snyk Code
4+
description: Runs 'snyk code test' command
5+
entry: src/main.sh "snyk-code"
6+
language: script
7+
pass_filenames: false
8+
verbose: true
9+
210
- id: snyk-container
311
name: Snyk Container
412
description: Runs 'snyk container test' command
5-
entry: hooks/snyk-container.sh
13+
entry: src/main.sh "snyk-container"
614
language: script
715
pass_filenames: true
816
files: Dockerfile
@@ -11,31 +19,23 @@
1119
- id: snyk-iac
1220
name: Snyk IaC
1321
description: Runs 'snyk iac test' command
14-
entry: hooks/snyk-iac.sh
15-
language: script
16-
pass_filenames: false
17-
verbose: true
18-
19-
- id: snyk-test
20-
name: Snyk Test
21-
description: Runs 'snyk test' command
22-
entry: hooks/snyk-test.sh
22+
entry: src/main.sh "snyk-iac"
2323
language: script
2424
pass_filenames: false
2525
verbose: true
2626

27-
- id: snyk-code
28-
name: Snyk Code
29-
description: Runs 'snyk code test' command
30-
entry: hooks/snyk-code.sh
27+
- id: snyk-log4shell
28+
name: Snyk log4shell
29+
description: Runs 'snyk log4shell' command
30+
entry: src/main.sh "snyk-log4shell"
3131
language: script
3232
pass_filenames: false
3333
verbose: true
3434

35-
- id: snyk-log4shell
36-
name: Snyk log4shell
37-
description: Runs 'snyk log4shell' command
38-
entry: hooks/snyk-log4shell.sh
35+
- id: snyk-test
36+
name: Snyk Test
37+
description: Runs 'snyk test' command
38+
entry: src/main.sh "snyk-test"
3939
language: script
4040
pass_filenames: false
4141
verbose: true

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.PHONY: build clean test
2+
3+
.DEFAULT_GOAL := build
4+
5+
build: clean
6+
@./scripts/build.sh
7+
8+
clean:
9+
@./scripts/clean.sh
10+
11+
test:
12+
@./tests/run.sh

0 commit comments

Comments
 (0)