Skip to content

Commit

Permalink
fix(check): properly fallback if no latest tag
Browse files Browse the repository at this point in the history
  • Loading branch information
eshepelyuk committed Jun 21, 2024
1 parent 5ae1660 commit 2221510
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 15 deletions.
129 changes: 121 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,135 @@
name: CI

on: push
on:
workflow_dispatch: {}
push: {}

jobs:
test:
check-all-success:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: cocogitto-action
- name: Initialise repository
run: |
git init
git config --global user.name 'Mona Lisa'
git config --global user.email '[email protected]'
echo 'cocogitto-action/' > .gitignore
echo '# Mona Lisa' > README.md
git add README.md .gitignore
git commit -m 'chore: add Mona Lisa docs'
- name: Run cocogitto-action
id: cog1
uses: ./cocogitto-action
continue-on-error: true
with:
check: true
check-latest-tag-only: false
release: false
- name: Checks
run: |
[ "${{ steps.cog1.outcome }}" == 'success' ] || exit 1
check-all-failure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: cocogitto-action
- name: Initialise repository
run: |
git init
git config --global user.name 'Mona Lisa'
git config --global user.email '[email protected]'
echo 'cocogitto-action/' > .gitignore
echo '# Mona Lisa' > README.md
git add README.md .gitignore
git commit -m 'add Mona Lisa docs'
- name: Run cocogitto-action
id: cog1
uses: ./cocogitto-action
continue-on-error: true
with:
check: true
check-latest-tag-only: false
release: false
- name: Checks
run: |
[ "${{ steps.cog1.outcome }}" == 'failure' ] || exit 1
check-only-last-has-last:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
path: cocogitto-action
- name: Initialise repository
run: |
git init
echo "# Mona Lisa" > README.md
git config --global user.name "Mona Lisa"
git config --global user.email "[email protected]"
git add README.md
git commit -m "docs: add Mona Lisa docs"
git config --global user.name 'Mona Lisa'
git config --global user.email '[email protected]'
echo 'cocogitto-action/' > .gitignore
echo '# Mona Lisa' > README.md
git add README.md .gitignore
git commit -m 'add Mona Lisa docs'
git tag '0.1.0'
git commit --allow-empty -m 'feat: new cool feature'
- name: Run cocogitto-action
id: cog1
uses: ./cocogitto-action
continue-on-error: true
with:
check: true
check-latest-tag-only: true
release: false
- run: |
git commit --allow-empty -m 'wrong commit format'
- name: Run cocogitto-action
id: cog2
uses: ./cocogitto-action
continue-on-error: true
with:
check: true
check-latest-tag-only: true
release: false
- name: Checks
run: |
[ "${{ steps.cog1.outcome }}" == 'success' ] || exit 1
[ "${{ steps.cog2.outcome }}" == 'failure' ] || exit 1
check-only-last-no-last:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: cocogitto-action
- name: Initialise repository
run: |
git init
git config --global user.name 'Mona Lisa'
git config --global user.email '[email protected]'
echo 'cocogitto-action/' > .gitignore
echo '# Mona Lisa' > README.md
git add README.md .gitignore
git commit -m 'chore: add Mona Lisa docs'
- name: Run cocogitto-action
id: cog1
uses: ./cocogitto-action
continue-on-error: true
with:
check: true
check-latest-tag-only: true
release: false
# - run: |
# git commit --allow-empty -m 'wrong commit format'
# - name: Run cocogitto-action
# id: cog2
# uses: ./cocogitto-action
# continue-on-error: true
# with:
# check: true
# check-latest-tag-only: true
# release: false
- name: Checks
run: |
[ "${{ steps.cog1.outcome }}" == 'success' ] || exit 1
# [ "${{ steps.cog2.outcome }}" == 'failure' ] || exit 1
16 changes: 9 additions & 7 deletions cog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ git config --global user.email "${GIT_USER_EMAIL}"

cog --version

if [ "${CHECK}" = "true" ]; then
if [ "${LATEST_TAG_ONLY}" = "true" ]; then
if [ "$(git describe --tags --abbrev=0)" ]; then
message="Checking commits from $(git describe --tags --abbrev=0)"
CURRENT_VERSION=$(cog get-version 2>/dev/null || echo '')

if [ "${CHECK}" = 'true' ]; then
if [ "${LATEST_TAG_ONLY}" = 'true' ]; then
if [ -n "${CURRENT_VERSION}" ]; then
echo "Checking commits from ${CURRENT_VERSION}"
cog check --from-latest-tag || exit 1
else
message="No tag found checking history from first commit"
echo 'No tag found checking history from first commit'
cog check || exit 1
fi
echo "${message}"
cog check --from-latest-tag || exit 1
else
echo "Checking all commits"
cog check || exit 1
Expand Down

0 comments on commit 2221510

Please sign in to comment.