From 234cdd4805e10f391964e4697a11873ec291413c Mon Sep 17 00:00:00 2001 From: Ievgenii Shepeliuk Date: Fri, 21 Jun 2024 16:16:27 +0300 Subject: [PATCH] fix(check): properly fallback if no latest tag --- .github/workflows/ci.yaml | 120 +++++++++++++++++++++++++++++++++++--- 1 file changed, 112 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c033446..7a8c056 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,11 +1,64 @@ 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 'mona.lisa@example.com' + 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 'mona.lisa@example.com' + 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: @@ -13,10 +66,61 @@ jobs: - name: Initialise repository run: | git init - echo "# Mona Lisa" > README.md - git config --global user.name "Mona Lisa" - git config --global user.email "mona.lisa@example.com" - git add README.md - git commit -m "docs: add Mona Lisa docs" + git config --global user.name 'Mona Lisa' + git config --global user.email 'mona.lisa@example.com' + 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 'mona.lisa@example.com' + # git commit --allow-empty -m 'feat: initial' + # git tag '0.1.0' + # 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: release + # uses: ./cocogitto-action + # with: + # check: true + # check-latest-tag-only: true + # release: false + # - name: Check outputs + # run: | + # [ "${{ steps.release.outputs.version }}" == '0.1.0' ] || exit 1 + # [ -z "${{ steps.release.outputs.bumped }}" ] || exit 1