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
48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test

on:
pull_request:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read

env:
GH_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ github.token }}
MISE_JOBS: 1

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v6

- name: Set up mise
uses: jdx/mise-action@v4
with:
install: true

- name: Install git-crypt backend
run: rudi install

- name: Check whitespace
run: git diff --check

- name: Run tests
run: mise run test

- name: Run codebase lints
run: codebase lint "$PWD"

- name: Check README.md is up to date
uses: KnickKnackLabs/readme@v0.3.1
with:
check: true
1 change: 1 addition & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ lint = [
"shellcheck",
"gum-table",
"caller-pwd-contract",
"github-actions",
]
16 changes: 16 additions & 0 deletions test/test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ REPO_DIR="$(cd "$BATS_TEST_DIRNAME/.." && pwd)"
# points at a different repo.
eval "$(cd "$REPO_DIR" && mise env)"

# Tests create and commit in many temporary repos, including cloned module repos
# that do not inherit local fixture git config. Provide a deterministic identity
# without relying on a developer or CI runner's global git config.
export GIT_AUTHOR_NAME="${GIT_AUTHOR_NAME:-modules tests}"
export GIT_AUTHOR_EMAIL="${GIT_AUTHOR_EMAIL:-modules-tests@example.invalid}"
export GIT_COMMITTER_NAME="${GIT_COMMITTER_NAME:-modules tests}"
export GIT_COMMITTER_EMAIL="${GIT_COMMITTER_EMAIL:-modules-tests@example.invalid}"

# Run a modules task through mise.
modules() {
if [ -z "${MODULES_CALLER_PWD:-}" ]; then
Expand All @@ -18,13 +26,20 @@ modules() {
}
export -f modules

configure_test_git_identity() {
local path="$1"
git -C "$path" config user.name "modules tests"
git -C "$path" config user.email "modules-tests@example.invalid"
}

# Create a local "remote" repo with some commits.
# Usage: create_remote_repo <path>
# Returns: the path, with a repo containing 2 commits.
create_remote_repo() {
local path="$1"
mkdir -p "$path"
git -C "$path" init -b main
configure_test_git_identity "$path"
git -C "$path" commit --allow-empty -m "initial commit"
echo "hello" > "$path/README.md"
git -C "$path" add README.md
Expand All @@ -37,6 +52,7 @@ create_parent_repo() {
local path="$1"
mkdir -p "$path"
git -C "$path" init -b main
configure_test_git_identity "$path"
git -C "$path" commit --allow-empty -m "initial commit"
}

Expand Down
Loading