Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(changelog, config)!: replace --topo-order by --date-order #58

Merged
merged 19 commits into from
Feb 12, 2022
Merged
50 changes: 50 additions & 0 deletions .github/actions/run-fixtures-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Run a fixtures test
description: Run a fixtures test

inputs:
fixtures-dir:
description: Path to the fixtures directory
required: true
command:
description: The git-cliff command to run
required: false
default: ""

runs:
using: composite
orhun marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Install git-cliff
run: cargo install --path git-cliff/
shell: bash

- name: Set git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
shell: bash

- name: Create commits and tags
working-directory: ${{ inputs.fixtures-dir }}
run: |
git init
./commit.sh
shell: bash

- name: Generate a changelog
working-directory: ${{ inputs.fixtures-dir }}
run: git cliff --config cliff.toml ${{ inputs.command }} > output.md
shell: bash

- name: Compare the output with the expected output
working-directory: ${{ inputs.fixtures-dir }}
run: |
cat output.md
diff --strip-trailing-cr output.md expected.md
shell: bash
59 changes: 0 additions & 59 deletions .github/fixtures/cliff.toml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/fixtures/test-date-order-arg/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://tera.netlify.app/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = """
<!-- generated by git-cliff -->
"""
12 changes: 12 additions & 0 deletions .github/fixtures/test-date-order-arg/commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e

GIT_COMMITTER_DATE="2021-01-23 01:23:45" git commit --allow-empty -m "feat: add feature 1"
git tag v0.1.0

GIT_COMMITTER_DATE="2021-01-23 01:23:46" git commit --allow-empty -m "feat: add feature 2"
git tag v0.2.0

git checkout v0.1.0
GIT_COMMITTER_DATE="2021-01-23 01:23:47" git commit --allow-empty -m "feat: fix feature 1"
git tag v0.1.1
11 changes: 11 additions & 0 deletions .github/fixtures/test-date-order-arg/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

All notable changes to this project will be documented in this file.

## [0.1.1] - 2021-01-23

### Feat

- Fix feature 1

<!-- generated by git-cliff -->
30 changes: 30 additions & 0 deletions .github/fixtures/test-date-order/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://tera.netlify.app/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = """
<!-- generated by git-cliff -->
"""

[git]
date_order = true
12 changes: 12 additions & 0 deletions .github/fixtures/test-date-order/commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e

GIT_COMMITTER_DATE="2021-01-23 01:23:45" git commit --allow-empty -m "feat: add feature 1"
git tag v0.1.0

GIT_COMMITTER_DATE="2021-01-23 01:23:46" git commit --allow-empty -m "feat: add feature 2"
git tag v0.2.0

git checkout v0.1.0
GIT_COMMITTER_DATE="2021-01-23 01:23:47" git commit --allow-empty -m "feat: fix feature 1"
git tag v0.1.1
11 changes: 11 additions & 0 deletions .github/fixtures/test-date-order/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

All notable changes to this project will be documented in this file.

## [0.1.1] - 2021-01-23

### Feat

- Fix feature 1

<!-- generated by git-cliff -->
33 changes: 33 additions & 0 deletions .github/fixtures/test-ignore-tags/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://tera.netlify.app/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = """
<!-- generated by git-cliff -->
"""

[git]
# regex for skipping tags
skip_tags = "v0.1.0-beta.1"
# regex for ignoring tags
ignore_tags = "v.*-beta.*"
15 changes: 15 additions & 0 deletions .github/fixtures/test-ignore-tags/commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e

GIT_COMMITTER_DATE="2021-01-23 01:23:45" git commit --allow-empty -m "feat: add skip feature"
git tag v0.1.0-beta.1

GIT_COMMITTER_DATE="2021-01-23 01:23:46" git commit --allow-empty -m "feat: add feature 1"
GIT_COMMITTER_DATE="2021-01-23 01:23:47" git commit --allow-empty -m "feat: fix feature 1"
git tag v0.1.0

GIT_COMMITTER_DATE="2021-01-23 01:23:48" git commit --allow-empty -m "feat: add feature 2"
git tag v0.2.0-beta.1

GIT_COMMITTER_DATE="2021-01-23 01:23:49" git commit --allow-empty -m "feat: add feature 3"
git tag v0.2.0
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ All notable changes to this project will be documented in this file.

## [0.2.0] - 2021-01-23

### Features
### Feat

- Add feature 2
- Add feature 3

## [0.1.0] - 2021-01-23

### Features
### Feat

- Add feature 1
- Fix feature 1
Expand Down
27 changes: 27 additions & 0 deletions .github/fixtures/test-topo-order/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://tera.netlify.app/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = """
<!-- generated by git-cliff -->
"""
12 changes: 12 additions & 0 deletions .github/fixtures/test-topo-order/commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e

GIT_COMMITTER_DATE="2021-01-23 01:23:45" git commit --allow-empty -m "feat: add feature 1"
git tag v0.1.0

GIT_COMMITTER_DATE="2021-01-23 01:23:46" git commit --allow-empty -m "feat: add feature 2"
git tag v0.2.0

git checkout v0.1.0
GIT_COMMITTER_DATE="2021-01-23 01:23:47" git commit --allow-empty -m "feat: fix feature 1"
git tag v0.1.1
11 changes: 11 additions & 0 deletions .github/fixtures/test-topo-order/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

All notable changes to this project will be documented in this file.

## [0.2.0] - 2021-01-23

### Feat

- Add feature 2

<!-- generated by git-cliff -->
50 changes: 16 additions & 34 deletions .github/workflows/test-fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,23 @@ jobs:
test-fixtures:
name: Test fixtures
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- fixtures-name: test-ignore-tags
- fixtures-name: test-topo-order
command: --latest
- fixtures-name: test-date-order
command: --latest
- fixtures-name: test-date-order-arg
command: --latest --date-order
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Run a fixtures test
uses: ./.github/actions/run-fixtures-test
with:
fetch-depth: 0
- name: Set git config
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
- name: Create commits and tags
run: |
mkdir .workspace && cd .workspace && git init
git commit --allow-empty -m "Initial commit"
git commit --allow-empty -m "feat: add skip feature"
git tag v0.1.0-beta.1
git commit --allow-empty -m "feat: add feature 1"
git commit --allow-empty -m "feat: fix feature 1"
git tag v0.1.0
git commit --allow-empty -m "feat: add feature 2"
git tag v0.2.0-beta.1
git commit --allow-empty -m "feat: add feature 3"
git tag v0.2.0
env:
GIT_AUTHOR_DATE: "2021-01-23 01:23:45"
GIT_COMMITTER_DATE: "2021-01-23 01:23:45"
- name: Generate a changelog
run: |
cd .workspace
fixtures_dir=${GITHUB_WORKSPACE}/.github/fixtures
docker run -t \
-v "$(pwd)/.git":/app/ \
-v "$fixtures_dir/cliff.toml":/app/cliff.toml \
orhunp/git-cliff:latest > "$fixtures_dir/output.md"
- name: Compare the output with the expected output
run: |
cd ${GITHUB_WORKSPACE}/.github/fixtures
cat output.md
diff --strip-trailing-cr output.md expected.md
fixtures-dir: .github/fixtures/${{ matrix.fixtures-name }}
command: ${{ matrix.command }}
Loading