Skip to content

Commit

Permalink
- updated pre-commit hooks to 1.1.5
Browse files Browse the repository at this point in the history
- added dependabot to check version used in github actionsa
- align github workflow with bash-tools-framework
  • Loading branch information
fchastanet committed Nov 19, 2023
1 parent 7425c9c commit d02e463
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 99 deletions.
36 changes: 23 additions & 13 deletions .framework-config
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034

REAL_SCRIPT_FILE="$(readlink -e "$(realpath "${BASH_SOURCE[0]}")")"
FRAMEWORK_ROOT_DIR="$(cd "$(readlink -e "${REAL_SCRIPT_FILE%/*}")" && pwd -P)"
FRAMEWORK_SRC_DIR="${FRAMEWORK_ROOT_DIR}/src"
REAL_SCRIPT_FILE="${REAL_SCRIPT_FILE:-$(readlink -e "$(realpath "${BASH_SOURCE[0]}")")}"
FRAMEWORK_ROOT_DIR="${FRAMEWORK_ROOT_DIR:-$(cd "$(readlink -e "${REAL_SCRIPT_FILE%/*}")" && pwd -P)}"
FRAMEWORK_SRC_DIR="${FRAMEWORK_SRC_DIR:-${FRAMEWORK_ROOT_DIR}/src}"
FRAMEWORK_BIN_DIR="${FRAMEWORK_BIN_DIR:-${FRAMEWORK_ROOT_DIR}/bin}"
FRAMEWORK_VENDOR_DIR="${FRAMEWORK_VENDOR_DIR:-${FRAMEWORK_ROOT_DIR}/vendor}"
FRAMEWORK_VENDOR_BIN_DIR="${FRAMEWORK_VENDOR_BIN_DIR:-${FRAMEWORK_ROOT_DIR}/vendor/bin}"

# describe the functions that will be skipped from being imported
FRAMEWORK_FUNCTIONS_IGNORE_REGEXP='^(Namespace::functions|Functions::myFunction|Namespace::requireSomething|IMPORT::dir::file|Acquire::ForceIPv4)$'
FRAMEWORK_FUNCTIONS_IGNORE_REGEXP="${FRAMEWORK_FUNCTIONS_IGNORE_REGEXP:-^(Namespace::functions|Functions::myFunction|Namespace::requireSomething|IMPORT::dir::file|Acquire::ForceIPv4)$}"
# describe the files that do not contain function to be imported
NON_FRAMEWORK_FILES_REGEXP="(^bin/|.framework-config|^install$|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/_binaries|^src/_includes|^src/batsHeaders.sh$|^conf)"
NON_FRAMEWORK_FILES_REGEXP="${NON_FRAMEWORK_FILES_REGEXP:-(^bin/|.framework-config|^install$|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/_binaries|^src/_includes|^src/batsHeaders.sh$|^conf)}"
# describe the files that are allowed to not have an associated bats file
BATS_FILE_NOT_NEEDED_REGEXP="(^bin/|.framework-config|^install$|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/batsHeaders.sh$|^src/_includes)"
BATS_FILE_NOT_NEEDED_REGEXP="${BATS_FILE_NOT_NEEDED_REGEXP:-(^bin/|.framework-config|^install$|.bats$|/testsData/|^manualTests/|/_.sh$|/ZZZ.sh$|/__all.sh$|^src/batsHeaders.sh$|^src/_includes)}"
# describe the files that are allowed to not have a function matching the filename
FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP="^conf/|^bin/|^\.framework-config$|^build.sh$|\.tpl$|testsData/binaryFile$"
FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP="${FRAMEWORK_FILES_FUNCTION_MATCHING_IGNORE_REGEXP:-^conf/|^bin/|^\.framework-config$|^build.sh$|\.tpl$|testsData/binaryFile$}"
# Source directories
FRAMEWORK_SRC_DIRS=(
"${FRAMEWORK_ROOT_DIR}/src"
"${FRAMEWORK_ROOT_DIR}/vendor/bash-tools-framework/src"
)
if [[ ! -v FRAMEWORK_SRC_DIRS ]]; then
FRAMEWORK_SRC_DIRS=(
"${FRAMEWORK_ROOT_DIR}/src"
"${FRAMEWORK_ROOT_DIR}/vendor/bash-tools-framework/src"
)
fi

export REPOSITORY_URL="https://github.com/fchastanet/bash-tools"
# export here all the variables that will be used in your templates
export REPOSITORY_URL="${REPOSITORY_URL:-https://github.com/fchastanet/bash-tools}"

export BASH_FRAMEWORK_DISPLAY_LEVEL="3"
BASH_FRAMEWORK_THEME="${BASH_FRAMEWORK_THEME:-default}"
BASH_FRAMEWORK_LOG_LEVEL="${BASH_FRAMEWORK_LOG_LEVEL:-0}"
BASH_FRAMEWORK_DISPLAY_LEVEL="${BASH_FRAMEWORK_DISPLAY_LEVEL:-3}"
BASH_FRAMEWORK_LOG_FILE="${BASH_FRAMEWORK_LOG_FILE:-${FRAMEWORK_ROOT_DIR}/logs/$(basename "$0").log}"
BASH_FRAMEWORK_LOG_FILE_MAX_ROTATION="${BASH_FRAMEWORK_LOG_FILE_MAX_ROTATION:-5}"
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Set update schedule for GitHub Actions

version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
# Check for updates to GitHub Actions every week
interval: 'weekly'
day: 'friday'
open-pull-requests-limit: 1
140 changes: 90 additions & 50 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,113 @@
name: Lint and test
on: # yamllint disable-line rule:truthy
push:
# execute when pushing only branches, not tags
branches:
- '**'
workflow_dispatch:

jobs:
linters:
build:
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
vendor:
- ubuntu
- alpine
bashTarVersion:
- '4.4'
- '5.0'
- '5.1'
include:
- vendor: ubuntu
bashImage: ubuntu:20.04
batsOptions: -j 30
bashTarVersion: 4.4
runPrecommitTests: false
- vendor: ubuntu
bashImage: ubuntu:20.04
bashTarVersion: 5.0
batsOptions: -j 30
runPrecommitTests: false
- vendor: ubuntu
bashImage: ubuntu:20.04
bashTarVersion: 5.1
batsOptions: -j 30
runPrecommitTests: true
- vendor: alpine
bashTarVersion: 4.4
bashImage: amd64/bash:4.4-alpine3.18
batsOptions: -j 30
runPrecommitTests: false
- vendor: alpine
bashTarVersion: 5.0
bashImage: amd64/bash:5.0-alpine3.18
batsOptions: -j 30
runPrecommitTests: false
- vendor: alpine
bashTarVersion: 5.1
bashImage: amd64/bash:5.1-alpine3.18
batsOptions: -j 30
runPrecommitTests: false
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: ouzi-dev/commit-status-updater@v2
with:
name: build bash-tools-${{matrix.vendor}}-${{matrix.bashTarVersion}}
status: pending

- name: Pull/Build/Push docker image
env:
BRANCH: ${GITHUB_REF##*/}
run: |
vendor/bash-tools-framework/bin/buildPushDockerImage \
--vendor "${{ matrix.vendor }}" \
--bash-version "${{ matrix.bashTarVersion }}" \
--bash-base-image "${{ matrix.bashImage }}" \
--branch-name "${GITHUB_REF##*/}" \
--push -vvv
- name: Check image
run: |
docker run --rm \
"build:bash-tools-${{ matrix.vendor }}-${{ matrix.bashTarVersion }}" bash \
--version
# only if pre-commit
- name: Set up Python
if: matrix.runPrecommitTests
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install pre-commit
if: matrix.runPrecommitTests
run: pip install pre-commit

- uses: ouzi-dev/commit-status-updater@v2
if: matrix.runPrecommitTests
with:
name: lint
status: pending

- name: Run pre-commit
if: matrix.runPrecommitTests
run: pre-commit run -a --hook-stage manual

- name: Archive results
if: ${{ always() }}
if: matrix.runPrecommitTests && always()
continue-on-error: true
uses: actions/upload-artifact@v3
with:
Expand All @@ -39,8 +118,8 @@ jobs:
megalinter-reports/**
- name: Create Pull Request
if: ${{ failure() }}
uses: peter-evans/create-pull-request@v4
if: matrix.runPrecommitTests && failure()
uses: peter-evans/create-pull-request@v5
with:
branch: update/pre-commit-fixes
title: lint fixes
Expand All @@ -50,57 +129,19 @@ jobs:
labels: updates

- uses: ouzi-dev/commit-status-updater@v2
if: always()
if: matrix.runPrecommitTests && always()
with:
name: lint
status: ${{ job.status }}

tests:
needs: linters
runs-on: ubuntu-22.04
strategy:
fail-fast: true
matrix:
vendor:
- ubuntu
- alpine
bashTarVersion:
- '4.4'
- '5.0'
- '5.1'
include:
- vendor: ubuntu
bashImage: ubuntu:20.04
options: -j 30
- vendor: alpine
bashImage: bash
options: -j 30
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: ouzi-dev/commit-status-updater@v2
with:
name: build bash-tools-${{matrix.vendor}}-${{matrix.bashTarVersion}}
status: pending

# Run unit tests
- name: run unit tests
run: |
set -exo pipefail
./bin/installRequirements
bin/installRequirements
chmod -R 777 logs
# shellcheck disable=SC2266
USER_ID=1000 \
GROUP_ID=1000 \
Expand All @@ -109,8 +150,8 @@ jobs:
--vendor "${{matrix.vendor}}" \
--bash-version "${{matrix.bashTarVersion}}" \
--bash-base-image "${{matrix.bashImage}}" \
--branch-name "${BRANCH}" \
${{matrix.options}} --report-formatter junit -o logs -r src --ci
--branch-name "${GITHUB_REF##*/}" \
${{matrix.batsOptions}} --report-formatter junit -o logs -r src --ci
- name: Upload Test Results
if: always()
Expand All @@ -128,7 +169,7 @@ jobs:
publishTestResults:
name: 'Publish Tests Results'
if: ${{ always() }}
needs: [linters, tests]
needs: [build]
runs-on: ubuntu-latest
permissions:
checks: write
Expand All @@ -153,7 +194,6 @@ jobs:
# You can get the conclusion via env (env.WORKFLOW_CONCLUSION)
- uses: technote-space/workflow-conclusion-action@v3

# run other action with the workflow conclusion
- uses: ouzi-dev/commit-status-updater@v2
with:
name: build
Expand Down
Loading

0 comments on commit d02e463

Please sign in to comment.