feat(examples): add a new more in-depth example #29
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| test-installs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: ./ | |
| - name: Test it was installed | |
| run: | | |
| cz version | |
| test-version: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: ./ | |
| with: | |
| version: 4.0.0 | |
| - name: Test version matches | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const assert = require('node:assert/strict'); | |
| const czVersion = await exec.getExecOutput('cz', ['version']); | |
| const expectedVersion = '4.0.0'; | |
| assert.equal(czVersion.stdout.trim(), expectedVersion); | |
| test-extra-requirements: | |
| strategy: | |
| matrix: | |
| extra_requirements: | |
| - pip_name: cz-conventional-gitmoji | |
| cz_name: cz_gitmoji | |
| - pip_name: cz-kpn | |
| cz_name: cz_kpn | |
| - pip_name: cz-kpn cz-conventional-gitmoji==0.7.0 | |
| cz_name: cz_kpn | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: ./ | |
| with: | |
| extra_requirements: ${{ matrix.extra_requirements.pip_name }} | |
| - name: Test extra requirements were installed | |
| uses: actions/github-script@v8 | |
| env: | |
| EXTRA_REQUIREMENTS: ${{ matrix.extra_requirements.cz_name }} | |
| with: | |
| script: | | |
| const assert = require('node:assert/strict'); | |
| const extraRequirements = process.env.EXTRA_REQUIREMENTS; | |
| const czList = await exec.getExecOutput('cz', ['ls']); | |
| const allItems = czList.stdout.trim().split('\n'); | |
| const result = allItems.includes(extraRequirements); | |
| assert.ok(result, `Expected ${extraRequirements} to be included in the list of installed cz plugins, but it was not.`); | |
| test-get-changelog: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - uses: ./ | |
| - name: Build changelog | |
| env: | |
| GIVEN_VERSION: "v0.1.0" | |
| run: | | |
| cz changelog --dry-run "${GIVEN_VERSION}" > .changelog.md | |
| - name: Verify changelog content | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const assert = require('node:assert/strict'); | |
| const fs = require('node:fs'); | |
| const changelogContent = fs.readFileSync('.changelog.md', 'utf8'); | |
| assert.ok(changelogContent.includes('v0.1.0 (2025-11-20)'), 'Expected changelog to contain version 0.1.0'); | |
| assert.ok(changelogContent.includes('### Feat'), 'Expected changelog to contain a header for features'); | |
| assert.ok(changelogContent.includes('### Fix'), 'Expected changelog to contain a header for fixes'); | |
| test-trigger-other-job: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - uses: ./ | |
| - id: get-version | |
| run: | | |
| current_version="$(cz version -p)" # ATTENTION: You may have to add the v* at the beginning of the version | |
| echo "current_version=$current_version" >> $GITHUB_OUTPUT | |
| - name: trigger other workflow | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh workflow list | |
| gh workflow run trigger-me.yaml --ref "${{ github.head_ref }}" -f "version=${{ steps.get-version.outputs.current_version }}" |