Skip to content

Merge pull request #27 from prog-time/issues-12 #27

Merge pull request #27 from prog-time/issues-12

Merge pull request #27 from prog-time/issues-12 #27

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install ShellCheck
run: sudo apt-get update && sudo apt-get install -y shellcheck
- name: Run ShellCheck on scripts
run: |
ERROR_FOUND=0
DIRS=("scripts" "docker/scripts")
for DIR in "${DIRS[@]}"; do
if [ ! -d "$DIR" ]; then
echo "⚠️ Directory $DIR does not exist. Skipping."
continue
fi
echo "ℹ️ Checking directory: $DIR"
sh_files=$(find "$DIR" -type f -name "*.sh")
if [ -z "$sh_files" ]; then
echo "No .sh files found in $DIR"
continue
fi
for file in $sh_files; do
echo "ℹ️ Checking $file..."
shellcheck --severity=warning "$file" || ERROR_FOUND=1
done
done
if [[ $ERROR_FOUND -eq 0 ]]; then
echo "✅ All shell scripts passed important ShellCheck checks!"
else
echo "❌ ShellCheck found important issues!"
exit 1
fi
bats:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install bats-core
run: |
git clone https://github.com/bats-core/bats-core.git /tmp/bats-core
sudo /tmp/bats-core/install.sh /usr/local
- name: Run BATS tests
run: bats --recursive tests/
markdownlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install markdownlint-cli
run: npm install -g markdownlint-cli
- name: Run markdownlint
run: |
set -euo pipefail
ERROR_FOUND=0
if [ ! -f ".markdownlint.yml" ]; then
echo "::error::Config file .markdownlint.yml not found"
exit 1
fi
mapfile -t md_files < <(find . -type f -name "*.md" \
-not -path "./node_modules/*" \
-not -path "./_site/*" \
-not -path "./.git/*" \
-not -path "./rules/*")
if [ ${#md_files[@]} -eq 0 ]; then
echo "⚠️ No .md files found. Skipping."
exit 0
fi
for file in "${md_files[@]}"; do
echo "ℹ️ Checking ${file#./}..."
markdownlint "$file" || ERROR_FOUND=1
done
if [[ $ERROR_FOUND -eq 0 ]]; then
echo "✅ All markdown files passed markdownlint checks!"
else
echo "❌ markdownlint found issues!"
exit 1
fi
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install yamllint
run: pip install yamllint
- name: Run yamllint
run: |
set -euo pipefail
ERROR_FOUND=0
if [ ! -f ".yamllint.yml" ]; then
echo "::error::Config file .yamllint.yml not found"
exit 1
fi
mapfile -t yaml_files < <(find . -type f \( -name "*.yml" -o -name "*.yaml" \) \
-not -path "./_site/*" \
-not -path "./node_modules/*" \
-not -path "./.git/*" \
-not -name ".yamllint.yml")
if [ ${#yaml_files[@]} -eq 0 ]; then
echo "⚠️ No YAML files found. Skipping."
exit 0
fi
for file in "${yaml_files[@]}"; do
echo "ℹ️ Checking ${file#./}..."
yamllint "$file" || ERROR_FOUND=1
done
if [[ $ERROR_FOUND -eq 0 ]]; then
echo "✅ All YAML files passed yamllint checks!"
else
echo "❌ yamllint found issues!"
exit 1
fi
assemble:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Assemble CI files
run: |
bash scripts/assemble-ci.sh scripts/CI/linters scripts/shell/linters CI/linters
bash scripts/assemble-ci.sh scripts/CI/static_analysis scripts/shell/static_analysis CI/static_analysis
bash scripts/assemble-ci.sh scripts/CI/tests scripts/shell/tests CI/tests
bash scripts/assemble-ci.sh scripts/CI/build scripts/shell/build CI/build
- name: Verify CI/ is up to date
run: |
if ! git diff --exit-code CI/; then
echo "::error::CI/ is out of date. Run the assembler and commit the changes."
exit 1
fi