diff --git a/.dictionary.txt b/.dictionary.txt new file mode 100644 index 0000000..9ac17d5 --- /dev/null +++ b/.dictionary.txt @@ -0,0 +1 @@ +crate diff --git a/.github/workflows/cancel_dupes.yml b/.github/workflows/cancel_dupes.yml index b08d598..346cf9e 100644 --- a/.github/workflows/cancel_dupes.yml +++ b/.github/workflows/cancel_dupes.yml @@ -2,10 +2,10 @@ name: Cancelling Duplicates on: workflow_run: workflows: - - 'Deploy to Docker Hub' - - 'Linting' - - 'Tests' - types: ['requested'] + - "Deploy to Docker Hub" + - "Linting" + - "Tests" + types: ["requested"] jobs: cancel-duplicate-workflow-runs: diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 65bcc79..d39a070 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -2,42 +2,38 @@ name: Linting on: pull_request: - branches: + branches: - master - main jobs: - shellcheck: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Pull koalaman/shellcheck:stable Image - run: docker pull koalaman/shellcheck:stable - - name: Run Shellcheck against shell scripts - run: docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*sh.*' {} \; | grep -v '/.git/') -# docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*execline.*' {} \; | grep -v '/.git/') + - uses: actions/checkout@v4 + - name: Pull koalaman/shellcheck:stable Image + run: docker pull koalaman/shellcheck:stable + - name: Run Shellcheck against shell scripts + run: docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*sh.*' {} \; | grep -v '/.git/') + # docker run --rm -i -v "$PWD:/mnt" koalaman/shellcheck:stable $(find . -type f -exec grep -m1 -l -E '^#!.*execline.*' {} \; | grep -v '/.git/') hadolint: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Pull hadolint/hadolint:latest Image - run: docker pull hadolint/hadolint:latest - - name: Run hadolint against Dockerfiles - run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint --ignore DL3008 --ignore SC2068 --ignore SC1091 --ignore DL3013 $(find . -type f -iname "Dockerfile*") + - uses: actions/checkout@v4 + - name: Pull hadolint/hadolint:latest Image + run: docker pull hadolint/hadolint:latest + - name: Run hadolint against Dockerfiles + run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint --ignore DL3008 --ignore SC2068 --ignore SC1091 --ignore DL3013 $(find . -type f -iname "Dockerfile*") markdownlint: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Pull markdownlint/markdownlint:latest Image - run: docker pull markdownlint/markdownlint:latest - - name: Run markdownlint against *.md files - run: docker run --rm -i -v "$(pwd)":/workdir --workdir /workdir markdownlint/markdownlint:latest --rules ~MD013,~MD033,~MD029 $(find . -type f -iname '*.md' | grep -v '/.git/') + - uses: actions/checkout@v4 + - name: Pull markdownlint/markdownlint:latest Image + run: docker pull markdownlint/markdownlint:latest + - name: Run markdownlint against *.md files + run: docker run --rm -i -v "$(pwd)":/workdir --workdir /workdir markdownlint/markdownlint:latest --rules ~MD013,~MD033,~MD029 $(find . -type f -iname '*.md' | grep -v '/.git/') diff --git a/.github/workflows/pre-commit-updates.yaml b/.github/workflows/pre-commit-updates.yaml new file mode 100644 index 0000000..f075972 --- /dev/null +++ b/.github/workflows/pre-commit-updates.yaml @@ -0,0 +1,23 @@ +name: Update pre-commit hooks + +on: + workflow_dispatch: + schedule: + - cron: 0 0 * * * + +jobs: + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.0 + with: + fetch-depth: 0 + - uses: vrslev/pre-commit-autoupdate@v1.0.0 + - uses: peter-evans/create-pull-request@v5 + with: + branch: pre-commit-autoupdate + title: "chore(deps): Update pre-commit hooks" + commit-message: "chore(deps): Update pre-commit hooks" + body: Update pre-commit hooks + labels: dependencies + delete-branch: True diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7a935b9..fb0cb95 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,17 +18,14 @@ jobs: - linux/arm/v7 - linux/i386 steps: - # Check out our code - - - name: Checkout + - name: Checkout uses: actions/checkout@v4 # Hit an issue where arm builds would fail with cURL errors regarding intermediary certificates when downloading from github (ie: deploy-s6-overlay). # After many hours of troubleshooting, the workaround is to pre-load the image's rootfs with the CA certificates from the runner. # This problem may go away in future. - - - name: Copy CA Certificates from GitHub Runner to Image rootfs + - name: Copy CA Certificates from GitHub Runner to Image rootfs run: | ls -la /etc/ssl/certs/ mkdir -p ./rootfs/etc/ssl/certs @@ -38,19 +35,16 @@ jobs: cp --no-dereference /usr/share/ca-certificates/mozilla/*.crt ./rootfs/usr/share/ca-certificates/mozilla # Set up QEMU for multi-arch builds - - - name: Set up QEMU + - name: Set up QEMU uses: docker/setup-qemu-action@v3 # Set up buildx for multi platform builds - - - name: Set up Docker Buildx + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 # Test container build for all supported platforms (defined above) - - - name: Test Build ${{ matrix.docker-platform }} + - name: Test Build ${{ matrix.docker-platform }} uses: docker/build-push-action@v5 with: context: . diff --git a/.gitignore b/.gitignore index 5f0cd9d..22372c7 100644 --- a/.gitignore +++ b/.gitignore @@ -165,4 +165,3 @@ pip-selfcheck.json # Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) .vscode/* - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..34ef282 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,65 @@ +repos: + # lint yaml, line and whitespace + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: requirements-txt-fixer + - id: mixed-line-ending + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + + # lint the dockerfiles + - repo: https://github.com/hadolint/hadolint + rev: v2.12.1-beta + hooks: + - id: hadolint + + # prettier + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v3.0.3" # Use the sha / tag you want to point at + hooks: + - id: prettier + types_or: [file, bash, sh, javascript, jsx, ts, tsx] + additional_dependencies: + - prettier@2.5.1 + exclude: ^(Dockerfile*) + + - repo: https://github.com/codespell-project/codespell.git + rev: "v2.2.5" # Use the sha / tag you want to point at + hooks: + - id: codespell + types: [text] + args: [--ignore-words=.dictionary.txt] + exclude: ^(Dockerfile*) + + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.9.0.6 + hooks: + - id: shellcheck + + - repo: https://github.com/sirosen/check-jsonschema + rev: 0.27.0 + hooks: + - id: check-github-actions + - id: check-github-workflows + + - repo: https://github.com/doublify/pre-commit-rust + rev: v1.0 + hooks: + - id: fmt + - id: cargo-check + + # lint python formatting + - repo: https://github.com/psf/black + rev: 23.9.1 + hooks: + - id: black + + - repo: https://github.com/pycqa/flake8 + rev: "6.1.0" # pick a git hash / tag to point to + hooks: + - id: flake8 + args: ["--extend-ignore=W503,W504,E501"] diff --git a/Dockerfile b/Dockerfile index b35b4f6..d3c21eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ COPY rootfs/ / SHELL ["/bin/bash", "-o", "pipefail", "-c"] +# hadolint ignore=DL3008,SC2086,SC2039,SC2068 RUN set -x && \ dpkg --add-architecture armhf && \ TEMP_PACKAGES=() && \ diff --git a/README.DockerHub.md b/README.DockerHub.md index ef6c596..ae5953e 100644 --- a/README.DockerHub.md +++ b/README.DockerHub.md @@ -11,4 +11,4 @@ For more information on what `pfclient` is, see here: /dev/null 2>&1; then +if /usr/local/bin/pfclient --version > /dev/null 2>&1; then # pfclient can be run natively s6-setuidgid nobody /usr/local/bin/pfclient \ --connection_type=1 \ @@ -32,4 +32,3 @@ else --log_path=/var/log/pfclient \ 2>&1 | mawk -W Interactive '{print "[pfclient_daemon] " $0}' fi - diff --git a/rootfs/firstrun b/rootfs/firstrun index 258e35a..8780a0d 100755 --- a/rootfs/firstrun +++ b/rootfs/firstrun @@ -2,7 +2,7 @@ #shellcheck shell=bash # Test pfclient can run natively (without qemu) -if /usr/local/bin/pfclient --version > /dev/null 2>&1; then +if /usr/local/bin/pfclient --version > /dev/null 2>&1; then # pfclient can be run natively s6-setuidgid nobody /usr/local/bin/pfclient @@ -11,4 +11,3 @@ else s6-setuidgid nobody qemu-arm-static /usr/local/bin/pfclient fi - diff --git a/rootfs/scripts/healthcheck.sh b/rootfs/scripts/healthcheck.sh index f8b2b38..e0046cf 100755 --- a/rootfs/scripts/healthcheck.sh +++ b/rootfs/scripts/healthcheck.sh @@ -1,4 +1,5 @@ #!/command/with-contenv bash +#shellcheck shell=bash # Import healthchecks-framework # shellcheck disable=SC1091