From 500190ed6c8918d17b75a30ed5802419300d9c8a Mon Sep 17 00:00:00 2001 From: cytopia Date: Fri, 28 Oct 2022 13:12:47 +0200 Subject: [PATCH 1/4] Multi-arch build --- .github/dependabot.yml | 8 + .github/labels.yml | 12 ++ .github/release-drafter.yml | 33 +++ .github/workflows/action_branch.yml | 38 ++++ .github/workflows/action_pull_request.yml | 35 ++++ .github/workflows/action_schedule.yml | 35 ++++ .github/workflows/lint.yml | 22 ++ .github/workflows/params.yml | 70 +++++++ .github/workflows/release-drafter.yml | 19 ++ .github/workflows/repository.yml | 25 +++ .gitignore | 2 + .travis.yml | 64 ------ .yamllint | 13 ++ Dockerfiles/Dockerfile.alpine | 1 + Dockerfile => Dockerfiles/Dockerfile.latest | 0 .../data}/aci-trailing-newline | 0 {data => Dockerfiles/data}/awesome-ci-lib.sh | 4 +- {data => Dockerfiles/data}/file-cr | 0 {data => Dockerfiles/data}/file-crlf | 0 {data => Dockerfiles/data}/file-empty | 0 {data => Dockerfiles/data}/file-nullbyte | 0 .../data}/file-trailing-newline | 0 .../data}/file-trailing-single-newline | 0 .../data}/file-trailing-space | 0 {data => Dockerfiles/data}/file-utf8 | 0 {data => Dockerfiles/data}/file-utf8-bom | 0 {data => Dockerfiles/data}/git-conflicts | 0 {data => Dockerfiles/data}/usage | 0 Makefile | 198 ++++++++++++------ 29 files changed, 444 insertions(+), 135 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/labels.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/action_branch.yml create mode 100644 .github/workflows/action_pull_request.yml create mode 100644 .github/workflows/action_schedule.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/params.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/repository.yml create mode 100644 .gitignore delete mode 100644 .travis.yml create mode 100644 .yamllint create mode 120000 Dockerfiles/Dockerfile.alpine rename Dockerfile => Dockerfiles/Dockerfile.latest (100%) rename {data => Dockerfiles/data}/aci-trailing-newline (100%) rename {data => Dockerfiles/data}/awesome-ci-lib.sh (99%) rename {data => Dockerfiles/data}/file-cr (100%) rename {data => Dockerfiles/data}/file-crlf (100%) rename {data => Dockerfiles/data}/file-empty (100%) rename {data => Dockerfiles/data}/file-nullbyte (100%) rename {data => Dockerfiles/data}/file-trailing-newline (100%) rename {data => Dockerfiles/data}/file-trailing-single-newline (100%) rename {data => Dockerfiles/data}/file-trailing-space (100%) rename {data => Dockerfiles/data}/file-utf8 (100%) rename {data => Dockerfiles/data}/file-utf8-bom (100%) rename {data => Dockerfiles/data}/git-conflicts (100%) rename {data => Dockerfiles/data}/usage (100%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8e85703 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +--- +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..9a507e8 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,12 @@ +# The labels in this file are automatically synced with the repository +# using the micnncim/action-label-syncer action. +--- +- name: C-dependency + color: 1abc9c + description: "Category: Dependency" +- name: PR-block + color: 3498db + description: "Pull Request: Do not merge" +- name: PR-merge + color: 3498db + description: "Pull Request: Merge when ready" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..03439b4 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,33 @@ +--- +name-template: '$RESOLVED_VERSION 🌈' +tag-template: '$RESOLVED_VERSION' +version-template: '$MAJOR.$MINOR' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: minor +template: | + ## Changes + + $CHANGES diff --git a/.github/workflows/action_branch.yml b/.github/workflows/action_branch.yml new file mode 100644 index 0000000..08a0c91 --- /dev/null +++ b/.github/workflows/action_branch.yml @@ -0,0 +1,38 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: build + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + push: + paths: + - 'Makefile' + - 'Dockerfiles/**' + - 'tests/**' + - '.github/workflows/action*.yml' + - '.github/workflows/params.yml' + +jobs: + + # (1/2) Determine repository params + params: + uses: ./.github/workflows/params.yml + + # (2/2) Build + docker: + needs: [params] + uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master + with: + enabled: true + can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }} + matrix: ${{ needs.params.outputs.matrix }} + refs: ${{ needs.params.outputs.refs }} + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} diff --git a/.github/workflows/action_pull_request.yml b/.github/workflows/action_pull_request.yml new file mode 100644 index 0000000..21b075b --- /dev/null +++ b/.github/workflows/action_pull_request.yml @@ -0,0 +1,35 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: build + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + pull_request: + + +jobs: + + # (1/2) Determine repository params + params: + uses: ./.github/workflows/params.yml + # Only run for forks (contributor) + if: github.event.pull_request.head.repo.fork + + # (2/2) Build + docker: + needs: [params] + uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master + with: + enabled: true + can_deploy: false + matrix: ${{ needs.params.outputs.matrix }} + refs: ${{ needs.params.outputs.refs }} + secrets: + dockerhub_username: "" + dockerhub_password: "" diff --git a/.github/workflows/action_schedule.yml b/.github/workflows/action_schedule.yml new file mode 100644 index 0000000..c25dfa2 --- /dev/null +++ b/.github/workflows/action_schedule.yml @@ -0,0 +1,35 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: nightly + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + # Runs daily + schedule: + - cron: '0 0 * * *' + + +jobs: + + # (1/2) Determine repository params + params: + uses: ./.github/workflows/params.yml + + # (2/2) Build + docker: + needs: [params] + uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master + with: + enabled: true + can_deploy: true + matrix: ${{ needs.params.outputs.matrix }} + refs: ${{ needs.params.outputs.refs }} + secrets: + dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} + dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..f83d099 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,22 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: lint + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + # Runs on Pull Requests + pull_request: + + +# ------------------------------------------------------------------------------------------------- +# What to run +# ------------------------------------------------------------------------------------------------- +jobs: + lint: + uses: devilbox/github-actions/.github/workflows/lint-generic.yml@master diff --git a/.github/workflows/params.yml b/.github/workflows/params.yml new file mode 100644 index 0000000..3f09a13 --- /dev/null +++ b/.github/workflows/params.yml @@ -0,0 +1,70 @@ +--- + +# ------------------------------------------------------------------------------------------------- +# Job Name +# ------------------------------------------------------------------------------------------------- +name: params + + +# ------------------------------------------------------------------------------------------------- +# Custom Variables +# ------------------------------------------------------------------------------------------------- +env: + MATRIX: >- + [ + { + "NAME": "fl", + "VERSION": ["latest"], + "FLAVOUR": ["alpine", "latest"], + "ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6"] + } + ] + + +# ------------------------------------------------------------------------------------------------- +# When to run +# ------------------------------------------------------------------------------------------------- +on: + workflow_call: + outputs: + matrix: + description: "The determined version matrix" + value: ${{ jobs.params.outputs.matrix }} + refs: + description: "The determined git ref matrix (only during scheduled run)" + value: ${{ jobs.params.outputs.refs }} + +jobs: + params: + runs-on: ubuntu-latest + + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + refs: ${{ steps.set-refs.outputs.matrix }} + + steps: + - name: "[Set-Output] Matrix" + id: set-matrix + run: | + echo "matrix=$( echo '${{ env.MATRIX }}' | jq -M -c )" >> $GITHUB_OUTPUT + + - name: "[Set-Output] Matrix 'Refs' (master branch and latest tag)" + id: set-refs + uses: cytopia/git-ref-matrix-action@v0.1.11 + with: + repository_default_branch: master + branches: master + num_latest_tags: 0 + if: github.event_name == 'schedule' + + - name: "[DEBUG] Show settings'" + run: | + echo 'Matrix' + echo '--------------------' + echo '${{ steps.set-matrix.outputs.matrix }}' + echo + + echo 'Matrix: Refs' + echo '--------------------' + echo '${{ steps.set-matrix-refs.outputs.matrix }}' + echo diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..1a63d7e --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,19 @@ +--- +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + publish: true + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_DRAFTER_TOKEN }} diff --git a/.github/workflows/repository.yml b/.github/workflows/repository.yml new file mode 100644 index 0000000..ca21e7d --- /dev/null +++ b/.github/workflows/repository.yml @@ -0,0 +1,25 @@ +--- +name: Repository + +on: + push: + branches: + - master + paths: + - .github/labels.yml + +jobs: + labels: + name: Labels + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Sync labels + uses: micnncim/action-label-syncer@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + manifest: .github/labels.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7457dff --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +Makefile.docker +Makefile.lint diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 13fa5c5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- - -### -### Enable sudo (required for docker service) -### -sudo: required - - -### -### Language -### -language: minimal - - -### -### Add services -### -services: - - docker - - -### -### Install requirements -### -install: - - retry() { - for ((n=0; n<10; n++)); do - echo "[${n}] ${*}"; - if eval "${*}"; then - return 0; - fi; - done; - return 1; - } - - -### -### Check generation changes, build and test -### -before_script: - - retry make lint - - retry make build TAG=${VERSION} - - retry make test TAG=${VERSION} - - -### -### Push to Dockerhub -### -script: - # Push to docker hub on success - - if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then - while ! make login USER="${DOCKER_USERNAME}" PASS="${DOCKER_PASSWORD}"; do sleep 1; done; - if [ -n "${TRAVIS_TAG}" ]; then - while ! make push TAG="${TRAVIS_TAG}"; do sleep 1; done; - elif [ "${TRAVIS_BRANCH}" == "master" ]; then - while ! make push; do sleep 1; done; - elif [[ ${TRAVIS_BRANCH} =~ ^(release-[.0-9]+)$ ]]; then - while ! make push TAG="${TRAVIS_BRANCH}"; do sleep 1; done; - else - echo "Skipping branch ${TRAVIS_BRANCH}"; - fi - else - echo "Skipping push on PR"; - fi diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..2c7758f --- /dev/null +++ b/.yamllint @@ -0,0 +1,13 @@ +--- +extends: default + +ignore: | + .yamllint + + +rules: + truthy: + allowed-values: ['true', 'false'] + check-keys: False + level: error + line-length: disable diff --git a/Dockerfiles/Dockerfile.alpine b/Dockerfiles/Dockerfile.alpine new file mode 120000 index 0000000..feb8875 --- /dev/null +++ b/Dockerfiles/Dockerfile.alpine @@ -0,0 +1 @@ +Dockerfile.latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfiles/Dockerfile.latest similarity index 100% rename from Dockerfile rename to Dockerfiles/Dockerfile.latest diff --git a/data/aci-trailing-newline b/Dockerfiles/data/aci-trailing-newline similarity index 100% rename from data/aci-trailing-newline rename to Dockerfiles/data/aci-trailing-newline diff --git a/data/awesome-ci-lib.sh b/Dockerfiles/data/awesome-ci-lib.sh similarity index 99% rename from data/awesome-ci-lib.sh rename to Dockerfiles/data/awesome-ci-lib.sh index e9dbf17..d377154 100644 --- a/data/awesome-ci-lib.sh +++ b/Dockerfiles/data/awesome-ci-lib.sh @@ -4,8 +4,8 @@ set -u # # Version # -MY_VERSION="0.17" -MY_DATE="2020-06-13" +MY_VERSION="0.18" +MY_DATE="2022-20-28" # # Credits diff --git a/data/file-cr b/Dockerfiles/data/file-cr similarity index 100% rename from data/file-cr rename to Dockerfiles/data/file-cr diff --git a/data/file-crlf b/Dockerfiles/data/file-crlf similarity index 100% rename from data/file-crlf rename to Dockerfiles/data/file-crlf diff --git a/data/file-empty b/Dockerfiles/data/file-empty similarity index 100% rename from data/file-empty rename to Dockerfiles/data/file-empty diff --git a/data/file-nullbyte b/Dockerfiles/data/file-nullbyte similarity index 100% rename from data/file-nullbyte rename to Dockerfiles/data/file-nullbyte diff --git a/data/file-trailing-newline b/Dockerfiles/data/file-trailing-newline similarity index 100% rename from data/file-trailing-newline rename to Dockerfiles/data/file-trailing-newline diff --git a/data/file-trailing-single-newline b/Dockerfiles/data/file-trailing-single-newline similarity index 100% rename from data/file-trailing-single-newline rename to Dockerfiles/data/file-trailing-single-newline diff --git a/data/file-trailing-space b/Dockerfiles/data/file-trailing-space similarity index 100% rename from data/file-trailing-space rename to Dockerfiles/data/file-trailing-space diff --git a/data/file-utf8 b/Dockerfiles/data/file-utf8 similarity index 100% rename from data/file-utf8 rename to Dockerfiles/data/file-utf8 diff --git a/data/file-utf8-bom b/Dockerfiles/data/file-utf8-bom similarity index 100% rename from data/file-utf8-bom rename to Dockerfiles/data/file-utf8-bom diff --git a/data/git-conflicts b/Dockerfiles/data/git-conflicts similarity index 100% rename from data/git-conflicts rename to Dockerfiles/data/git-conflicts diff --git a/data/usage b/Dockerfiles/data/usage similarity index 100% rename from data/usage rename to Dockerfiles/data/usage diff --git a/Makefile b/Makefile index 2e3e05f..d46cab2 100644 --- a/Makefile +++ b/Makefile @@ -2,113 +2,173 @@ ifneq (,) .error This Makefile requires GNU Make. endif -.PHONY: build rebuild lint test _test-req _test-run-succ _test-run-fail tag pull login push enter +# Ensure additional Makefiles are present +MAKEFILES = Makefile.docker Makefile.lint +$(MAKEFILES): URL=https://raw.githubusercontent.com/devilbox/makefiles/master/$(@) +$(MAKEFILES): + @if ! (curl --fail -sS -o $(@) $(URL) || wget -O $(@) $(URL)); then \ + echo "Error, curl or wget required."; \ + echo "Exiting."; \ + false; \ + fi +include $(MAKEFILES) + +# Set default Target +.DEFAULT_GOAL := help + + +# ------------------------------------------------------------------------------------------------- +# Default configuration +# ------------------------------------------------------------------------------------------------- +# Own vars +TAG = latest + +# Makefile.docker overwrites +NAME = file-lint +VERSION = latest +IMAGE = cytopia/file-lint +FLAVOUR = latest +FILE = Dockerfile.${FLAVOUR} +DIR = Dockerfiles + +# Building from master branch: Tag == 'latest' +ifeq ($(strip $(TAG)),latest) + ifeq ($(strip $(VERSION)),latest) + DOCKER_TAG = $(FLAVOUR) + else + ifeq ($(strip $(FLAVOUR)),latest) + DOCKER_TAG = $(VERSION) + else + DOCKER_TAG = $(FLAVOUR)-$(VERSION) + endif + endif +# Building from any other branch or tag: Tag == '' +else + ifeq ($(strip $(FLAVOUR)),latest) + DOCKER_TAG = $(VERSION)-$(TAG) + else + DOCKER_TAG = $(FLAVOUR)-$(VERSION)-$(TAG) + endif +endif + +# Makefile.lint overwrites +FL_IGNORES = .git/,.github/,tests/ +SC_IGNORES = .git/,.github/,tests/ +JL_IGNORES = .git/,.github/ + -CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +# ------------------------------------------------------------------------------------------------- +# Default Target +# ------------------------------------------------------------------------------------------------- +.PHONY: help +help: + @echo "lint Lint project files and repository" + @echo + @echo "build [ARCH=...] [TAG=...] Build Docker image" + @echo "rebuild [ARCH=...] [TAG=...] Build Docker image without cache" + @echo "push [ARCH=...] [TAG=...] Push Docker image to Docker hub" + @echo + @echo "manifest-create [ARCHES=...] [TAG=...] Create multi-arch manifest" + @echo "manifest-push [TAG=...] Push multi-arch manifest" + @echo + @echo "test [ARCH=...] Test built Docker image" + @echo -DIR = . -FILE = Dockerfile -IMAGE = cytopia/file-lint -TAG = latest -build: - docker build -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) +# ------------------------------------------------------------------------------------------------- +# Docker Targets +# ------------------------------------------------------------------------------------------------- +.PHONY: build +build: ARGS=--build-arg VERSION=$(VERSION) +build: docker-arch-build -rebuild: pull - docker build --no-cache -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) +.PHONY: rebuild +rebuild: ARGS=--build-arg VERSION=$(VERSION) +rebuild: docker-arch-rebuild -lint: - @docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-cr --text --ignore '.git/,.github/,tests/' --path . - @docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-crlf --text --ignore '.git/,.github/,tests/' --path . - @docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-trailing-single-newline --text --ignore '.git/,.github/,tests/' --path . - @docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-trailing-space --text --ignore '.git/,.github/,tests/' --path . - @docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-utf8 --text --ignore '.git/,.github/,tests/' --path . - @docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-utf8-bom --text --ignore '.git/,.github/,tests/' --path . +.PHONY: push +push: docker-arch-push -test: - @$(MAKE) --no-print-directory _test-req - @$(MAKE) --no-print-directory _test-run-succ - @$(MAKE) --no-print-directory _test-run-fail + +# ------------------------------------------------------------------------------------------------- +# Manifest Targets +# ------------------------------------------------------------------------------------------------- +.PHONY: manifest-create +manifest-create: docker-manifest-create + +.PHONY: manifest-push +manifest-push: docker-manifest-push + + +# ------------------------------------------------------------------------------------------------- +# Test Targets +# ------------------------------------------------------------------------------------------------- +.PHONY: test +test: _test-req +test: _test-run-succ +test: _test-run-fail _test-req: @echo "------------------------------------------------------------" @echo "- Testing requirements" @echo "------------------------------------------------------------" - @docker run --rm $(IMAGE) file-empty --info - @docker run --rm $(IMAGE) file-cr --info - @docker run --rm $(IMAGE) file-crlf --info - @docker run --rm $(IMAGE) file-nullbyte --info - @docker run --rm $(IMAGE) file-trailing-newline --info - @docker run --rm $(IMAGE) file-trailing-single-newline --info - @docker run --rm $(IMAGE) file-trailing-space --info - @docker run --rm $(IMAGE) file-utf8 --info - @docker run --rm $(IMAGE) file-utf8-bom --info - @docker run --rm $(IMAGE) git-conflicts --info + docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) file-empty --info + docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) file-cr --info + docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) file-crlf --info + docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) file-nullbyte --info + docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) file-trailing-newline --info + docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) file-trailing-single-newline --info + docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) file-trailing-space --info + docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) file-utf8 --info + docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) file-utf8-bom --info + docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) git-conflicts --info _test-run-succ: @echo "------------------------------------------------------------" @echo "- Runtime test: False positives" @echo "------------------------------------------------------------" - @docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-empty --path . - @docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-cr --path . - @docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-crlf --path . - @docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-nullbyte --path . - @docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-trailing-newline --path . - @docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-trailing-single-newline --path . - @docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-trailing-space --path . - @docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-utf8 --path . - @docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) file-utf8-bom --path . - @docker run --rm -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE) git-conflicts --path . + @docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) file-empty --path . + @docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) file-cr --path . + @docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) file-crlf --path . + @docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) file-nullbyte --path . + @docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) file-trailing-newline --path . + @docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) file-trailing-single-newline --path . + @docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) file-trailing-space --path . + @docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) file-utf8 --path . + @docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) file-utf8-bom --path . + @docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/ok:/data $(IMAGE):$(DOCKER_TAG) git-conflicts --path . _test-run-fail: @echo "------------------------------------------------------------" @echo "- Runtime test: True flaws" @echo "------------------------------------------------------------" - @if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) file-empty --path .; then \ + @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/err:/data $(IMAGE):$(DOCKER_TAG) file-empty --path .; then \ exit 1; \ fi - @if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) file-cr --path .; then \ + @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/err:/data $(IMAGE):$(DOCKER_TAG) file-cr --path .; then \ exit 1; \ fi - @if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) file-crlf --path .; then \ + @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/err:/data $(IMAGE):$(DOCKER_TAG) file-crlf --path .; then \ exit 1; \ fi - @if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) file-nullbyte --path .; then \ + @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/err:/data $(IMAGE):$(DOCKER_TAG) file-nullbyte --path .; then \ exit 1; \ fi - @if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) file-trailing-newline --path .; then \ + @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/err:/data $(IMAGE):$(DOCKER_TAG) file-trailing-newline --path .; then \ exit 1; \ fi - @if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) file-trailing-single-newline --path .; then \ + @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/err:/data $(IMAGE):$(DOCKER_TAG) file-trailing-single-newline --path .; then \ exit 1; \ fi - @if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) file-trailing-space --path .; then \ + @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/err:/data $(IMAGE):$(DOCKER_TAG) file-trailing-space --path .; then \ exit 1; \ fi - @if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) file-utf8 --path .; then \ + @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/err:/data $(IMAGE):$(DOCKER_TAG) file-utf8 --path .; then \ exit 1; \ fi - @if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) file-utf8-bom --path .; then \ + @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/err:/data $(IMAGE):$(DOCKER_TAG) file-utf8-bom --path .; then \ exit 1; \ fi - @if docker run --rm -v $(CURRENT_DIR)/tests/err:/data $(IMAGE) git-conflicts --path .; then \ + @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests/err:/data $(IMAGE):$(DOCKER_TAG) git-conflicts --path .; then \ exit 1; \ fi - -tag: - docker tag $(IMAGE) $(IMAGE):$(TAG) - -pull: - @grep -E '^\s*FROM' Dockerfile \ - | sed -e 's/^FROM//g' -e 's/[[:space:]]*as[[:space:]]*.*$$//g' \ - | xargs -n1 docker pull; - -login: - yes | docker login --username $(USER) --password $(PASS) - -push: - @$(MAKE) tag TAG=$(TAG) - docker push $(IMAGE):$(TAG) - -enter: - docker run --rm --name $(subst /,-,$(IMAGE)) -it $(ARG) $(IMAGE):$(TAG) bash From acc645ca23a9dc6ae9a2c42d8f96148f464be8c5 Mon Sep 17 00:00:00 2001 From: cytopia Date: Fri, 28 Oct 2022 13:26:40 +0200 Subject: [PATCH 2/4] Fix Linting --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d46cab2..f64763b 100644 --- a/Makefile +++ b/Makefile @@ -53,8 +53,8 @@ endif # Makefile.lint overwrites FL_IGNORES = .git/,.github/,tests/ -SC_IGNORES = .git/,.github/,tests/ -JL_IGNORES = .git/,.github/ +SC_IGNORES = .git/,.github/,tests/,Dockerfiles/data/awesome-ci-lib.sh +JL_IGNORES = .git/,.github/,./tests/ # ------------------------------------------------------------------------------------------------- From 00abe0ebf9db95a417110a1fdb7e0aa463342106 Mon Sep 17 00:00:00 2001 From: cytopia Date: Fri, 28 Oct 2022 13:27:08 +0200 Subject: [PATCH 3/4] Update README --- README.md | 83 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index af32b0d..91395d3 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,20 @@ # Docker image for `file-lint` -[![Build Status](https://travis-ci.com/cytopia/docker-file-lint.svg?branch=master)](https://travis-ci.com/cytopia/docker-file-lint) [![Tag](https://img.shields.io/github/tag/cytopia/docker-file-lint.svg)](https://github.com/cytopia/docker-file-lint/releases) -[![](https://images.microbadger.com/badges/version/cytopia/file-lint:latest.svg?&kill_cache=1)](https://microbadger.com/images/cytopia/file-lint:latest "file-lint") -[![](https://images.microbadger.com/badges/image/cytopia/file-lint:latest.svg?&kill_cache=1)](https://microbadger.com/images/cytopia/file-lint:latest "file-lint") -[![](https://img.shields.io/docker/pulls/cytopia/file-lint.svg)](https://hub.docker.com/r/cytopia/file-lint) [![](https://img.shields.io/badge/github-cytopia%2Fdocker--file--lint-red.svg)](https://github.com/cytopia/docker-file-lint "github.com/cytopia/docker-file-lint") [![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT) +[![lint](https://github.com/cytopia/docker-file-lint/workflows/lint/badge.svg)](https://github.com/cytopia/docker-file-lint/actions?query=workflow%3Alint) +[![build](https://github.com/cytopia/docker-file-lint/workflows/build/badge.svg)](https://github.com/cytopia/docker-file-lint/actions?query=workflow%3Abuild) +[![nightly](https://github.com/cytopia/docker-file-lint/workflows/nightly/badge.svg)](https://github.com/cytopia/docker-file-lint/actions?query=workflow%3Anightly) + + > #### All [#awesome-ci](https://github.com/topics/awesome-ci) Docker images > -> [ansible][ansible-git-lnk] **•** > [ansible-lint][alint-git-lnk] **•** +> [ansible][ansible-git-lnk] **•** > [awesome-ci][aci-git-lnk] **•** +> [bandit][bandit-git-lnk] **•** > [black][black-git-lnk] **•** > [checkmake][cm-git-lnk] **•** > [eslint][elint-git-lnk] **•** @@ -21,36 +23,63 @@ > [goimports][gimp-git-lnk] **•** > [golint][glint-git-lnk] **•** > [jsonlint][jlint-git-lnk] **•** +> [kubeval][kubeval-git-lnk] **•** > [linkcheck][linkcheck-git-lnk] **•** > [mypy][mypy-git-lnk] **•** +> [php-cs-fixer][pcsf-git-lnk] **•** > [phpcbf][pcbf-git-lnk] **•** > [phpcs][pcs-git-lnk] **•** > [phplint][plint-git-lnk] **•** -> [php-cs-fixer][pcsf-git-lnk] **•** > [pycodestyle][pycs-git-lnk] **•** > [pydocstyle][pyds-git-lnk] **•** > [pylint][pylint-git-lnk] **•** > [terraform-docs][tfdocs-git-lnk] **•** -> [terragrunt][tg-git-lnk] **•** > [terragrunt-fmt][tgfmt-git-lnk] **•** +> [terragrunt][tg-git-lnk] **•** > [yamlfmt][yfmt-git-lnk] **•** > [yamllint][ylint-git-lnk] -> #### All [#awesome-ci](https://github.com/topics/awesome-ci) Makefiles -> -> Visit **[cytopia/makefiles](https://github.com/cytopia/makefiles)** for seamless project integration, minimum required best-practice code linting and CI. - -View **[Dockerfile](https://github.com/cytopia/docker-file-lint/blob/master/Dockerfile)** on GitHub. +View **[Dockerfiles](https://github.com/cytopia/docker-file-lint/blob/master/Dockerfiles/)** on GitHub. -[![Docker hub](http://dockeri.co/image/cytopia/file-lint?&kill_cache=1)](https://hub.docker.com/r/cytopia/file-lint) +**Available Architectures:** `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` Tiny Alpine-based Docker image for the very basics of CI against your code files based one [awesome-ci](https://github.com/topics/awesome-ci)[1]. [1] Original project: https://github.com/topics/awesome-ci -## Features +## :whale: Available Docker image versions + +[![](https://img.shields.io/docker/pulls/cytopia/file-lint.svg)](https://hub.docker.com/r/cytopia/file-lint) +[![Docker](https://badgen.net/badge/icon/:latest?icon=docker&label=cytopia/file-lint)](https://hub.docker.com/r/cytopia/file-lint) + +#### Rolling releaess + +The following Docker image tags are rolling releases and are built and updated every night. + +[![nightly](https://github.com/cytopia/docker-file-lint/workflows/nightly/badge.svg)](https://github.com/cytopia/docker-file-lint/actions?query=workflow%3Anightly) + + +| Docker Tag | Git Ref | file-lint | Flavour | Available Architectures | +|----------------------|-----------|--------------|---------|----------------------------------------------| +| `latest` | master | latest | default | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | +| `alpine` | master | latest | Alpine | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | + +#### Point in time releases + +The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date. + +[![build](https://github.com/cytopia/docker-file-lint/workflows/build/badge.svg)](https://github.com/cytopia/docker-file-lint/actions?query=workflow%3Abuild) + + +| Docker Tag | Git Ref | file-lint | Flavour | Available Architectures | +|----------------------|-----------|--------------|---------|----------------------------------------------| +| `latest-0.11` | tag: 0.11 | latest | default | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | +| `alpine-latest-0.11` | tag: 0.11 | latest | Alpine | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | + + +## :star: Features ### Overview * dry run (which shows all piped unix command voodoo for learning) @@ -86,20 +115,13 @@ Tiny Alpine-based Docker image for the very basics of CI against your code files > Tools extracted from https://github.com/cytopia/awesome-ci -## Available Docker image versions - -| Docker tag | Build from | -|------------|------------| -| `latest` | Current stable file-lint version | -| `` | Git tag from this repository | - -## Docker mounts +## :open_file_folder: Docker mounts The working directory inside the Docker container is **`/data/`** and should be mounted locally. -## Usage +## :computer: Usage ### General ```bash @@ -371,7 +393,7 @@ _lint-git-conflicts: ``` -## Related [#awesome-ci](https://github.com/topics/awesome-ci) projects +## :arrows_counterclockwise: Related [#awesome-ci](https://github.com/topics/awesome-ci) projects ### Docker images @@ -390,11 +412,13 @@ linter below for reproducible local or remote CI tests: | [golint][glint-git-lnk] | [![glint-hub-img]][glint-hub-lnk] | Go | Lint Go code | | [eslint][elint-git-lnk] | [![elint-hub-img]][elint-hub-lnk] | Javascript | Lint Javascript code | | [jsonlint][jlint-git-lnk] | [![jlint-hub-img]][jlint-hub-lnk] | JSON | Lint JSON files **[1]** | +| [kubeval][kubeval-git-lnk] | [![kubeval-hub-img]][kubeval-hub-lnk] | K8s | Lint Kubernetes files | | [checkmake][cm-git-lnk] | [![cm-hub-img]][cm-hub-lnk] | Make | Lint Makefiles | | [phpcbf][pcbf-git-lnk] | [![pcbf-hub-img]][pcbf-hub-lnk] | PHP | PHP Code Beautifier and Fixer | | [phpcs][pcs-git-lnk] | [![pcs-hub-img]][pcs-hub-lnk] | PHP | PHP Code Sniffer | | [phplint][plint-git-lnk] | [![plint-hub-img]][plint-hub-lnk] | PHP | PHP Code Linter **[1]** | | [php-cs-fixer][pcsf-git-lnk] | [![pcsf-hub-img]][pcsf-hub-lnk] | PHP | PHP Coding Standards Fixer | +| [bandit][bandit-git-lnk] | [![bandit-hub-img]][bandit-hub-lnk] | Python | A security linter from PyCQA | [black][black-git-lnk] | [![black-hub-img]][black-hub-lnk] | Python | The uncompromising Python code formatter | | [mypy][mypy-git-lnk] | [![mypy-hub-img]][mypy-hub-lnk] | Python | Static source code analysis | | [pycodestyle][pycs-git-lnk] | [![pycs-hub-img]][pycs-hub-lnk] | Python | Python style guide checker | @@ -432,6 +456,10 @@ linter below for reproducible local or remote CI tests: [alint-hub-img]: https://img.shields.io/docker/pulls/cytopia/ansible-lint.svg [alint-hub-lnk]: https://hub.docker.com/r/cytopia/ansible-lint +[kubeval-git-lnk]: https://github.com/cytopia/docker-kubeval +[kubeval-hub-img]: https://img.shields.io/docker/pulls/cytopia/kubeval.svg +[kubeval-hub-lnk]: https://hub.docker.com/r/cytopia/kubeval + [gfmt-git-lnk]: https://github.com/cytopia/docker-gofmt [gfmt-hub-img]: https://img.shields.io/docker/pulls/cytopia/gofmt.svg [gfmt-hub-lnk]: https://hub.docker.com/r/cytopia/gofmt @@ -468,6 +496,10 @@ linter below for reproducible local or remote CI tests: [pcsf-hub-img]: https://img.shields.io/docker/pulls/cytopia/php-cs-fixer.svg [pcsf-hub-lnk]: https://hub.docker.com/r/cytopia/php-cs-fixer +[bandit-git-lnk]: https://github.com/cytopia/docker-bandit +[bandit-hub-img]: https://img.shields.io/docker/pulls/cytopia/bandit.svg +[bandit-hub-lnk]: https://hub.docker.com/r/cytopia/bandit + [black-git-lnk]: https://github.com/cytopia/docker-black [black-hub-img]: https://img.shields.io/docker/pulls/cytopia/black.svg [black-hub-lnk]: https://hub.docker.com/r/cytopia/black @@ -515,7 +547,8 @@ Visit **[cytopia/makefiles](https://github.com/cytopia/makefiles)** for dependen The provided Makefiles will only require GNU Make and Docker itself removing the need to install anything else. -## License +## :page_facing_up: License + **[MIT License](LICENSE)** From b3052e767bedbf924085c425fd42f7d658551dab Mon Sep 17 00:00:00 2001 From: cytopia Date: Fri, 28 Oct 2022 13:37:30 +0200 Subject: [PATCH 4/4] Update README --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 91395d3..e3d0991 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,6 @@ The following Docker image tags are built once and can be used for reproducible ## :star: Features -### Overview * dry run (which shows all piped unix command voodoo for learning) * project based configuration file (`awesome-ci.conf`) * check for empty files @@ -98,7 +97,7 @@ The following Docker image tags are built once and can be used for reproducible - check files by specific shebang only - check binary or text-files only -### Tools +## :wrench: Tools | Type | Tool | Fixable | Description | |------|------|---------|-------------| | File | [file-cr](data/file-cr) | ✓ | Scan files and check if they contain CR (Carriage Return only). |