Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/bats_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Bats Tests

on:
pull_request:
branches:
- main

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-bats-tests
cancel-in-progress: true

jobs:
actionlint:
name: Validate GitHub Workflows (actionlint)
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Install actionlint
run: |
ACTIONLINT_VERSION="1.7.7"
curl -sSfL "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" \
| tar -xz
sudo mv actionlint /usr/local/bin/actionlint
actionlint -version

- name: Run Workflow Linter
run: actionlint

shellcheck:
name: Lint Shell Scripts (shellcheck)
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Install shellcheck
run: |
sudo apt-get update -y
sudo apt-get install -y shellcheck

- name: Run Shell Linter
run: shellcheck scripts/*.sh

shfmt:
name: Check Shell Formatting (shfmt)
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Install shfmt
run: |
sudo apt-get update -y
sudo apt-get install -y shfmt

- name: Run Shell Formatter Check
run: git ls-files '*.sh' '*.bash' '*.bats' | xargs shfmt -d -i 4 -ci

bats:
name: Run Shell Test Suite (bats)
needs:
- shellcheck
- shfmt
- actionlint
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Install bats (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y bats

- name: Install bats (macOS)
if: runner.os == 'macOS'
run: brew install bats-core

- name: Run bats Test Suite
run: bats --recursive tests/bats
15 changes: 13 additions & 2 deletions .github/workflows/extra_soundness.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
type: boolean
description: "Boolean to enable run tests with .build cache."
default: false
tests_cache_enabled:
type: boolean
description: "Boolean to enable .build cache usage inside the run tests job."
default: true
run_tests_swift_versions:
type: string
description: "List of Swift versions to test with."
Expand Down Expand Up @@ -126,11 +130,13 @@ jobs:
ssh-keyscan github.com >> ~/.ssh/known_hosts

- name: Install zstd
if: ${{ inputs.tests_cache_enabled }}
run: |
sudo apt-get update -y
sudo apt-get install -y zstd

- name: Restore .build
if: ${{ inputs.tests_cache_enabled }}
id: "restore-build"
uses: actions/cache/restore@v4
with:
Expand All @@ -142,11 +148,16 @@ jobs:
run: swift build --build-tests

- name: Cache .build
if: steps.restore-build.outputs.cache-hit != 'true'
if: ${{ inputs.tests_cache_enabled && steps.restore-build.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: .build
key: "swiftpm-tests-build-${{ runner.os }}-${{ matrix.swift }}-${{ github.event.pull_request.base.sha || github.event.after }}"

- name: Run unit tests
run: swift test --skip-build --parallel
run: |
if [ "${{ inputs.tests_cache_enabled }}" = "true" ]; then
swift test --skip-build --parallel
else
swift test --parallel
fi
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,16 @@ format:
package:
curl -s $(baseUrl)/check-swift-package.sh | bash

lint-shell:
curl -s $(baseUrl)/script-format.sh | bash

format-shell:
curl -s $(baseUrl)/script-format.sh | bash -s -- --fix

lint-workflows:
curl -s $(baseUrl)/run-actionlint.sh | bash

check: symlinks language deps lint docc-warnings headers

test-bats:
bats --recursive tests/bats
Loading