Skip to content

Commit fc8bbcd

Browse files
committed
feat(ci): introduce new setup-cz action
1 parent 482c4c4 commit fc8bbcd

File tree

6 files changed

+217
-0
lines changed

6 files changed

+217
-0
lines changed

.cz.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
commitizen:
3+
major_version_zero: true
4+
name: cz_conventional_commits
5+
tag_format: v$version
6+
update_changelog_on_bump: true
7+
version: 0.0.1
8+
version_scheme: semver2

.github/workflows/test.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test-installs:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
- uses: ./
14+
- name: Test it was installed
15+
run: |
16+
cz version
17+
test-version:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v5
21+
- uses: ./
22+
with:
23+
version: 4.0.0
24+
- name: Test version matches
25+
uses: actions/github-script@v8
26+
with:
27+
script: |
28+
const assert = require('node:assert/strict');
29+
const czVersion = await exec.getExecOutput('cz', ['version']);
30+
const expectedVersion = '4.0.0';
31+
assert.equal(czVersion.stdout.trim(), expectedVersion);
32+
test-extra-requirements:
33+
strategy:
34+
matrix:
35+
extra_requirements:
36+
- pip_name: cz-conventional-gitmoji
37+
cz_name: cz_gitmoji
38+
- pip_name: cz-kpn
39+
cz_name: cz_kpn
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v5
43+
- uses: ./
44+
with:
45+
extra_requirements: ${{ matrix.extra_requirements.pip_name }}
46+
- name: Test extra requirements were installed
47+
uses: actions/github-script@v8
48+
env:
49+
EXTRA_REQUIREMENTS: ${{ matrix.extra_requirements.cz_name }}
50+
with:
51+
script: |
52+
const assert = require('node:assert/strict');
53+
const extraRequirements = process.env.EXTRA_REQUIREMENTS;
54+
const czList = await exec.getExecOutput('cz', ['ls']);
55+
const allItems = czList.stdout.trim().split('\n');
56+
const result = allItems.includes(extraRequirements);
57+
assert.ok(result, `Expected ${extraRequirements} to be included in the list of installed cz plugins, but it was not.`);

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[codz]
4+
*$py.class
5+
6+
# nix
7+
.direnv
8+
result
9+
.envrc
10+
11+
# python
12+
.venv/
13+
venv/

action.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Setup commitizen CLI
2+
description: |
3+
This workflow sets up the commitizen CLI for use in your GitHub workflows.
4+
Unlike `commitizen-action`, this workflow only installs the CLI.
5+
It does not automatically bump, commit or push changes.
6+
This workflow, instead, gives more flexibility to the user by letting them
7+
use the full range of commitizen commands.
8+
9+
inputs:
10+
version:
11+
description: "Version of commitizen to install"
12+
required: false
13+
default: "latest"
14+
extra_requirements:
15+
description: "Install extra dependencies"
16+
required: false
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- uses: actions/setup-python@v6
22+
- id: set-vars
23+
shell: python
24+
env:
25+
COMMITIZEN_VERSION: ${{ inputs.version }}
26+
run: |
27+
import os
28+
commitizen_version = os.environ.get("COMMITIZEN_VERSION", "").strip()
29+
if commitizen_version == "latest":
30+
set_commitizen_version = ""
31+
else:
32+
set_commitizen_version = f"=={commitizen_version}"
33+
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
34+
fh.write(f"COMMITIZEN_VERSION={set_commitizen_version}\n")
35+
- name: Install commitizen
36+
shell: bash
37+
env:
38+
COMMITIZEN_VERSION: ${{ steps.set-vars.outputs.COMMITIZEN_VERSION }}
39+
EXTRA_REQUIREMENTS: ${{ inputs.extra_requirements }}
40+
run: |
41+
pip install -U commitizen${COMMITIZEN_VERSION} ${EXTRA_REQUIREMENTS}

flake.lock

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
description = "A development shell";
3+
inputs = {
4+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5+
};
6+
outputs =
7+
inputs@{
8+
flake-parts,
9+
...
10+
}:
11+
# https://flake.parts/
12+
flake-parts.lib.mkFlake { inherit inputs; } {
13+
systems = [
14+
"x86_64-linux"
15+
"aarch64-darwin"
16+
"x86_64-darwin"
17+
];
18+
perSystem =
19+
{ pkgs, ... }:
20+
{
21+
# Default shell opened with `nix develop`
22+
devShells.default = pkgs.mkShell {
23+
name = "dev";
24+
25+
# Available packages on https://search.nixos.org/packages
26+
buildInputs = with pkgs; [
27+
python3
28+
nodejs
29+
commitizen
30+
];
31+
32+
shellHook = ''
33+
echo "Welcome to the devshell!"
34+
'';
35+
};
36+
};
37+
};
38+
}

0 commit comments

Comments
 (0)