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
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: v1.6.1
_commit: v1.6.3
_src_path: https://github.com/DeveloperC286/template
project_name: conventional_commits_next_version
uses_git: true
26 changes: 21 additions & 5 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ permissions:
contents: read

jobs:
permissions:
name: Permissions
runs-on: ${{ matrix.architecture }}
strategy:
matrix:
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
language: [shell]
steps:
- name: Checkout code.
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Check permissions.
run: make check-${{ matrix.language }}-permissions

formatting:
name: Formatting
runs-on: ${{ matrix.architecture }}
Expand All @@ -27,7 +40,7 @@ jobs:
strategy:
matrix:
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
language: [rust, shell]
language: [rust, shell, python]
steps:
- name: Checkout code.
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
Expand All @@ -36,17 +49,20 @@ jobs:
- name: Check linting.
run: nix develop -c make check-${{ matrix.language }}-linting

scripts-permissions:
name: Scripts Permissions
dependencies:
name: Dependencies
runs-on: ${{ matrix.architecture }}
strategy:
matrix:
architecture: [ubuntu-24.04, ubuntu-24.04-arm]
language: [rust]
steps:
- name: Checkout code.
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: Check scripts permissions.
run: make check-scripts-permissions
- name: Setup Nix.
uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31.9.0
- name: Check dependencies.
run: nix develop -c make check-${{ matrix.language }}-dependencies

compile:
name: Compile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Linting
runs-on: ubuntu-24.04
container:
image: ghcr.io/developerc286/conventional_commits_linter:0.17.0@sha256:d6fb0dfd79c2e06897692bc3f0dc62bcb7ce90a92030c81a3137935516d525d7
image: ghcr.io/developerc286/conventional_commits_linter:0.17.1@sha256:f1b947937ee884ba7f886d04939cd4858f9aeafb50dcf94925a516c50e43021b
steps:
- name: Checkout code.
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/git-history.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Clean
runs-on: ubuntu-24.04
container:
image: ghcr.io/developerc286/clean_git_history:1.1.5@sha256:b1374591d48393f6b5fcc888f6bc7da05f7d218961f7850112130b1cad78186a
image: ghcr.io/developerc286/clean_git_history:1.1.6@sha256:93fd9c692f6e629956921b8d068ccad33760882b6e0c6d4d32cd963380aec25f
steps:
- name: Checkout code.
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ anyhow = "1.0.89"
[dev-dependencies]
# For parameterized testing.
rstest = "=0.26.1"

[package.metadata.cargo-machete]
ignored = ["strum"]
51 changes: 33 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
# Auto-detect musl target for static binaries (Linux only)
# Only set MUSL_TARGET on supported architectures; targets that need it will check
MUSL_TARGET := $(shell uname -m | sed 's/^x86_64$$/x86_64-unknown-linux-musl/;s/^aarch64$$/aarch64-unknown-linux-musl/')
ifeq ($(filter %unknown-linux-musl,$(MUSL_TARGET)),)
$(error Unsupported architecture: $(shell uname -m). Static musl builds only supported on Linux x86_64 and aarch64)
endif

define check-musl-target
$(if $(filter %unknown-linux-musl,$(MUSL_TARGET)),,$(error Unsupported architecture: $(shell uname -m). Static musl builds only supported on Linux x86_64 and aarch64))
endef

# Use --locked in CI to ensure reproducible builds
CARGO_LOCKED := $(if $(CI),--locked,)

.PHONY: default
default: compile

.PHONY: check-shell-permissions
check-shell-permissions:
./ci/check-scripts-permissions.sh

.PHONY: check-rust-formatting
check-rust-formatting:
cargo fmt --all -- --check --config=group_imports=StdExternalCrate

.PHONY: check-shell-formatting
check-shell-formatting:
shfmt --simplify --diff ci/*

.PHONY: check-python-formatting
check-python-formatting:
autopep8 --exit-code --diff --aggressive --aggressive --max-line-length 120 --recursive end-to-end-tests/

.PHONY: check-yaml-formatting
check-yaml-formatting:
yamlfmt -verbose -lint -dstar .github/workflows/*

.PHONY: fix-rust-formatting
fix-rust-formatting:
cargo fmt --all -- --config=group_imports=StdExternalCrate

.PHONY: check-shell-formatting
check-shell-formatting:
shfmt --simplify --diff ci/*

.PHONY: fix-shell-formatting
fix-shell-formatting:
shfmt --simplify --write ci/*

.PHONY: check-python-formatting
check-python-formatting:
autopep8 --exit-code --diff --aggressive --aggressive --max-line-length 120 --recursive end-to-end-tests/

.PHONY: fix-python-formatting
fix-python-formatting:
autopep8 --in-place --aggressive --aggressive --max-line-length 120 --recursive end-to-end-tests/

.PHONY: check-yaml-formatting
check-yaml-formatting:
yamlfmt -verbose -lint -dstar .github/workflows/*

.PHONY: fix-yaml-formatting
fix-yaml-formatting:
yamlfmt -verbose -dstar .github/workflows/*
Expand All @@ -50,13 +56,21 @@ check-rust-linting:
check-shell-linting:
shellcheck ci/*.sh

.PHONY: check-python-linting
check-python-linting:
ruff check --line-length 120 end-to-end-tests/

.PHONY: fix-python-linting
fix-python-linting:
ruff check --fix --line-length 120 end-to-end-tests/

.PHONY: check-github-actions-workflows-linting
check-github-actions-workflows-linting:
actionlint -verbose -color

.PHONY: check-scripts-permissions
check-scripts-permissions:
./ci/check-scripts-permissions.sh
.PHONY: check-rust-dependencies
check-rust-dependencies:
cargo machete

.PHONY: compile
compile:
Expand All @@ -72,6 +86,7 @@ end-to-end-test: compile

.PHONY: release
release:
$(call check-musl-target)
cargo build --release --target=$(MUSL_TARGET) --locked --verbose

.PHONY: publish-binary
Expand Down
4 changes: 2 additions & 2 deletions end-to-end-tests/features/steps/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def assert_error_contains(result, error):


def assert_error_matches_regex(result, regex):
assert regex.match(result.stderr) is not None, f"Expected standard error to match the regex.\n" + \
assert regex.match(result.stderr) is not None, "Expected standard error to match the regex.\n" + \
f"Standard error = {result.stderr.encode()}.\n" + \
f"Regex = {regex.pattern.encode()}.\n"

Expand All @@ -43,6 +43,6 @@ def assert_error_is_one_of(result, errors):


def assert_next_version(result, expected_next_version):
assert result.stdout == expected_next_version, f"The next version was not what was expected.\n" + \
assert result.stdout == expected_next_version, "The next version was not what was expected.\n" + \
f"Expected = {expected_next_version}.\n" + \
f"Actual = {result.stdout}\n"
11 changes: 10 additions & 1 deletion end-to-end-tests/features/steps/then.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
from behave import then

from utilities import execute_conventional_commits_next_version
from assertions import *
from assertions import (
assert_command_successful,
assert_command_unsuccessful,
assert_error_contains,
assert_error_equals,
assert_error_matches_regex,
assert_next_version,
assert_no_errors,
assert_no_output,
)


@then('the returned version should be "{expected_next_version}".')
Expand Down
15 changes: 11 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,22 @@
buildInputs = [
# Rust with cross-compilation targets built-in.
rustWithTargets
# Shell scripts.
# Shell formatting.
pkgs.shfmt
pkgs.shellcheck
# GitHub Action Workflows.
# Python formatting.
pkgs.python313Packages.autopep8
# YAML formatting.
pkgs.yamlfmt
# Shell linting.
pkgs.shellcheck
# Python linting.
pkgs.ruff
# GitHub Actions workflows linting.
pkgs.actionlint
# Rust dependencies check.
pkgs.cargo-machete
# End to end tests.
pkgs.python313
pkgs.python313Packages.autopep8
pkgs.python313Packages.behave
pkgs.git
# Deploying.
Expand Down