cocogitto / cocogitto-action

A github action to ensure your current gitlog respect the conventional commit specification
22 stars 17 forks source link

[BUG] Cocogitto-action crash on cocogitto 5.6.0 config file #14

Closed cyboooooorg closed 8 months ago

cyboooooorg commented 10 months ago

Hi everyone,

I installed cocogitto 5.6.0 and did a cog init in my project. Here the generated file :

from_latest_tag = false
ignore_merge_commits = false
generate_mono_repository_global_tag = true
branch_whitelist = []
skip_untracked = false
pre_bump_hooks = []
post_bump_hooks = []
pre_package_bump_hooks = []
post_package_bump_hooks = []

[git_hooks]

[commit_types]

[changelog]
path = "CHANGELOG.md"
authors = []

[bump_profiles]

[packages]

And now my github action is crashing with the following error:

Setting git user : cog-bot
Settings git user email cog@demo.org
Error: failed to parse config

    cause unknown field `skip_untracked`, expected one of `ignore_merge_commits`, `branch_whitelist`, `tag_prefix`, `pre_bump_hooks`, `post_bump_hooks`, `commit_types`, `changelog`, `bump_profiles`

Error: Process completed with exit code 1.

I suggest that cocogitto-action must ignore the new field or be updated to use cocogitto 5.6.0 😄

nagyben commented 9 months ago

I'm experiencing the same error, it seems like the github action is not compatible with the v.5.6.0 config file, it does not recognize the majority of the configuration options from the docs

oknozor commented 9 months ago

Hey, I will update the action to use the latest cocogitto version as soon as possible. Sorry for the inconvenience.

nagyben commented 9 months ago

I have also raised https://github.com/cocogitto/cocogitto-action/pull/15 as sanity check to see which version of cog is being run

cyboooooorg commented 9 months ago

I think the problem is already solved, i'm not sure but when i use cocogitto/cocogitto-action@v3.5 and not the v3 it seems that works...

Here is my workflow.yml and my cog.toml:

Here is workflow.yml

name: Generate Release

on:
  pull_request:
    types: [closed]
    branches:
      - main

jobs:
  release:
    if: |
      github.event.pull_request.merged == true &&
      ${{ !contains(github.event.pull_request.title, '[Chore] Update changelog') }}
    name: SemVer release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - run: |
          git config user.name github-actions
          git config user.email github-actions@github.com
          git config --global user.email github-actions@github.com
          git config --global user.name github-actions

      - name: Prepare SemVer release
        id: prepare-release
        uses: cocogitto/cocogitto-action@v3.5
        with:
          git-user-email: "github-actions@github.com"
          git-user: "github-actions"
          check-latest-tag-only: true
          release: true

      - name: Generate Changelog
        id: generate-changelog
        run: |
          {
            echo 'CHANGELOG<<EOF'
            cog changelog --at ${{ steps.prepare-release.outputs.version }} -t full_hash
            echo EOF
          } >> "$GITHUB_OUTPUT"

      - name: Create Pull Request
        id: create-pull-request
        uses: peter-evans/create-pull-request@v5
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: "chore: update changelog"
          committer: GitHub <noreply@github.com>
          author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
          signoff: false
          branch: update-changelog
          delete-branch: true
          title: "[Chore] Update changelog"
          body: ${{ steps.generate-changelog.outputs.CHANGELOG }}
          labels: |
            documentation
            automated pr
          assignees: Cyboooooorg
          reviewers: Cyboooooorg
          draft: false

      - name: Upload github release
        uses: softprops/action-gh-release@v1
        with:
          body: ${{ steps.generate-changelog.outputs.CHANGELOG }}
          tag_name: ${{ steps.prepare-release.outputs.version }}
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Enable Pull Request Automerge
        run: gh pr merge --merge --auto -d "${{ steps.create-pull-request.outputs.pull-request-number }}"
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Here is cog.toml

# Ignore merge commits from conventional commit checks
ignore_merge_commits = true

# A list of command to run BEFORE creating a version.
# All change generated by those commands will be committed with the generated version commit.
# `{{version}}` will be interpretted as your target version
pre_bump_hooks = []

# A list of command to run AFTER creating a version.
# `{{version}}` will be interpretted as your target version
post_bump_hooks = []

[changelog]
path = "CHANGELOG.md"
template = "remote"
remote = "github.com"
repository = "idle-space-empire"
owner = "Cyboooooorg"
authors = [
  { signature = "Cyborg", username = "Cyboooooorg" }
]

[commit_types]
chore = { changelog_title = "", omit_from_changelog = true }

# ? Setting git hooks
[git_hooks.commit-msg]
path = "hooks/git-commit-msg.sh"

[git_hooks.pre-push]
path = "hooks/git-pre-push.sh"

[git_hooks.post-rewrite]
path = "hooks/git-post-rewrite.sh"
nagyben commented 9 months ago

@Cyboooooorg nice catch, I also noticed that the action v3.5 is using cog v5.4.0.

It's possible to use the @main tag for now to pick up the latest version of the action

i.e.

- name: check conventional commits
  uses: cocogitto/cocogitto-action@main
                                   ^^^^