diff --git a/.githooks/commit-msg b/.githooks/commit-msg deleted file mode 100644 index b3cca0c..0000000 --- a/.githooks/commit-msg +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -if [ -z "$1" ]; then - echo "Missing argument (commit message). Did you try to run this manually?" - exit 1 -fi - -commitTitle="$(head -n 1 < "$1")" - -# ignore merge -if echo "$commitTitle" | grep -qE "^Merge"; then - echo "Commit hook: ignoring merge" - exit 0 -fi - -# check commit message -REGEX='^(feat|fix|docs|style|refactor|ci|test|chore|comment)\(.*\)\:.*' -if ! echo "$commitTitle" | grep -qE "${REGEX}"; then - echo "Your commit title '$commitTitle' did not follow conventional commit message rules:" - echo "Please comply with the regex ${REGEX}" - exit 1 -fi diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..e3d1d93 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,45 @@ +name: 🐞 Bug report or Support Request +description: Create a report to help us improve. +labels: [bug] +body: + - type: checkboxes + attributes: + label: Preliminary checklist + description: Please complete the following checks before submitting an issue. + options: + - label: I am using the latest stable version of DDEV + required: true + - label: I am using the latest stable version of this action + required: true + - type: textarea + attributes: + label: Expected Behavior + description: What did you expect to happen? + validations: + required: true + - type: textarea + attributes: + label: Actual Behavior + description: What actually happened instead? + validations: + required: true + - type: textarea + attributes: + label: Steps To Reproduce + description: Specific steps to reproduce the behavior. + placeholder: | + 1. In this environment... + 2. With this config... + 3. Run `...` + 4. See error... + validations: + required: false + - type: textarea + attributes: + label: Anything else? + description: | + Links? References? Screenshots? Anything that will give us more context about your issue! + + 💡 Attach images or log files by clicking this area to highlight it and dragging files in. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..db21167 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,35 @@ +name: 🚀 Feature request +description: Suggest an idea for this project. +labels: [enhancement] +body: + - type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search existing issues to see if one already exists for your request. + options: + - label: I have searched the existing issues + required: true + - type: textarea + attributes: + label: Is your feature request related to a problem? + description: Clearly and concisely describe the problem. (Ex. I'm always frustrated when...) + validations: + required: true + - type: textarea + attributes: + label: Describe your solution + description: Clearly and concisely describe what you want to happen. + validations: + required: true + - type: textarea + attributes: + label: Describe alternatives + description: Clearly and concisely describe any alternative solutions or features you've considered. + validations: + required: false + - type: textarea + attributes: + label: Additional context + description: Add any other context or screenshots about the feature request. + validations: + required: false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ec9b430 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,23 @@ +## The Issue + +- Fixes #REPLACE_ME_WITH_RELATED_ISSUE_NUMBER + + + +## How This PR Solves The Issue + + + +## Manual Testing Instructions + + + +## Automated Testing Overview + + + +## Release/Deployment Notes + +Don't create releases manually. Follow the [release process documentation](https://github.com/ddev/github-action-add-on-test/blob/main/docs/DEVELOPER.md#release-process) when making a new release. + + diff --git a/.github/workflows/add-on-disable-checkout-test.yml b/.github/workflows/add-on-disable-checkout-test.yml index 783739a..204295d 100644 --- a/.github/workflows/add-on-disable-checkout-test.yml +++ b/.github/workflows/add-on-disable-checkout-test.yml @@ -8,8 +8,6 @@ on: pull_request: paths-ignore: - "**.md" - schedule: - - cron: "25 08 * * THU" workflow_dispatch: permissions: @@ -45,5 +43,4 @@ jobs: addon_repository: ${{ env.ADD_ON }} addon_ref: ${{ env.ADD_ON_REF }} addon_path: tested-addon - keepalive: false disable_checkout_action: true diff --git a/.github/workflows/add-ons-test.yml b/.github/workflows/add-ons-test.yml index 95f09d2..00adce4 100644 --- a/.github/workflows/add-ons-test.yml +++ b/.github/workflows/add-ons-test.yml @@ -11,6 +11,19 @@ on: schedule: - cron: "25 08 * * *" workflow_dispatch: + inputs: + action_ref: + description: The ref to use for the action (tag, branch, SHA) + required: false + type: string + default: "" + workflow_call: + inputs: + action_ref: + description: The ref to use for the action (tag, branch, SHA) + required: false + type: string + default: "" permissions: contents: read @@ -22,16 +35,24 @@ jobs: matrix: ddev_version: [stable, HEAD] add_on: - - ddev/ddev-redis-commander - - ddev/ddev-mongo - - ddev/ddev-adminer - - ddev/ddev-redis - - ddev/ddev-solr - - ddev/ddev-sqlsrv - - ddev/ddev-pdfreactor - - ddev/ddev-memcached - - ddev/ddev-cron - - ddev/ddev-elasticsearch + - name: ddev/ddev-redis-commander + test_command: "bats tests" + - name: ddev/ddev-mongo + test_command: "" + - name: ddev/ddev-adminer + test_command: "" + - name: ddev/ddev-redis + test_command: "" + - name: ddev/ddev-solr + test_command: "" + - name: ddev/ddev-pdfreactor + test_command: "" + - name: ddev/ddev-memcached + test_command: "" + - name: ddev/ddev-cron + test_command: "" + - name: ddev/ddev-elasticsearch + test_command: "" name: Add-on test runs-on: ubuntu-latest @@ -41,15 +62,24 @@ jobs: uses: actions/checkout@v4 - name: Retrieve last tag of add-on + id: last_tag run: | - echo "ADD_ON_LAST_TAG=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/${{ matrix.add_on }}/releases/latest | grep -oP "\/tag\/\K(.*)$")" >> $GITHUB_ENV + echo "add_on_last_tag=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/${{ matrix.add_on.name }}/releases/latest | grep -oP "\/tag\/\K(.*)$")" >> $GITHUB_OUTPUT - - name: Run add-on test (${{ matrix.ddev_version }}) - uses: ./ + - name: Set action ref + env: + ACTION_REF: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.action_ref || inputs.action_ref }} + id: set_action_call + run: | + if [ -z "${{ env.ACTION_REF }}" ] + then + echo "action_ref=$(echo './')" >> $GITHUB_OUTPUT + else + echo "action_ref=$(echo ddev/ddev-add-on-test/@${{ env.ACTION_REF }})" >> $GITHUB_OUTPUT + fi + + - name: Run add-on test + uses: jenseng/dynamic-uses@v1 with: - ddev_version: ${{ matrix.ddev_version }} - token: ${{ secrets.GITHUB_TOKEN }} - addon_repository: ${{ matrix.add_on }} - addon_ref: ${{ env.ADD_ON_LAST_TAG }} - addon_path: tested-addon - keepalive: false + uses: ${{ steps.set_action_call.outputs.action_ref }} + with: '{"ddev_version": "${{ matrix.ddev_version }}", "token": "${{ secrets.GITHUB_TOKEN }}", "addon_repository": "${{ matrix.add_on.name }}", "addon_ref": "${{ steps.last_tag.outputs.add_on_last_tag }}", "addon_path": "tested-addon", "test_command": "${{ matrix.add_on.test_command }}" }' diff --git a/.github/workflows/markdown.yml b/.github/workflows/doc-links.yml similarity index 66% rename from .github/workflows/markdown.yml rename to .github/workflows/doc-links.yml index 588e572..49254c8 100644 --- a/.github/workflows/markdown.yml +++ b/.github/workflows/doc-links.yml @@ -1,13 +1,20 @@ +name: Documentation links + on: workflow_dispatch: + push: + branches: + - main + pull_request: + branches: + - main -name: Markdown files test and update permissions: - contents: write - pull-requests: write + contents: read + jobs: - markdown-test-and-update: - name: Markdown files test and update + markdown-test-links: + name: Markdown test links runs-on: ubuntu-latest steps: - name: Clone sources @@ -30,10 +37,4 @@ jobs: gem install awesome_bot cd sources awesome_bot README.md --skip-save-results --allow-dupe --base-url http://localhost:8080/ --white-list ddev.site - - - uses: technote-space/toc-generator@v4 - with: - MAX_HEADER_LEVEL: 3 - TARGET_PATHS: "README.md" - CHECK_ONLY_DEFAULT_BRANCH: true - CREATE_PR: true + awesome_bot docs/*.md --skip-save-results --allow-dupe --base-url http://localhost:8080/docs/ --white-list ddev.site diff --git a/.github/workflows/keepalive.yml b/.github/workflows/keepalive.yml deleted file mode 100644 index 87ea4a9..0000000 --- a/.github/workflows/keepalive.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Keep Alive -on: - schedule: - - cron: "0 3 * * 4" - -permissions: - contents: write - -jobs: - keep-alive: - name: Keep Alive - runs-on: ubuntu-latest - - steps: - - name: Clone project files - uses: actions/checkout@v4 - - # keepalive-workflow keeps GitHub from turning off tests after 60 days - - uses: gautamkrishnar/keepalive-workflow@v2 - with: - time_elapsed: 50 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1d66bed..0418aa6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,17 +2,11 @@ name: Create Release # example: gh workflow run release.yml -f tag_name=v1.1.4 on: workflow_dispatch: - branches: - - main inputs: tag_name: description: Tag name type: string required: true - first-release: - type: boolean - description: First release - default: false jobs: create-release: @@ -22,36 +16,41 @@ jobs: contents: write outputs: - version_number: ${{ steps.set-outputs.outputs.version_number }} - major_tag: ${{ steps.set-outputs.outputs.major_tag }} + version_number: ${{ steps.set-version-number.outputs.version_number }} + major_tag: ${{ steps.set-major-tag.outputs.major_tag }} + + env: + TAG_NAME: ${{ github.event.inputs.tag_name }} steps: - name: Check naming convention run: | - VERIF=$(echo ${{ github.event.inputs.tag_name }} | grep -E "^v([0-9]{1,}\.)([0-9]{1,}\.)([0-9]{1,})(-(alpha|beta)\.[0-9]{1,})?$") + VERIF=$(echo ${{ env.TAG_NAME }} | grep -E "^v([0-9]{1,}\.)([0-9]{1,}\.)([0-9]{1,})(-(alpha|beta)\.[0-9]{1,})?$") if [ ! ${VERIF} ] then - echo "Tag name '${{ github.event.inputs.tag_name }}' does not comply with naming convention vX.Y.Z" + echo "Tag name '${{ env.TAG_NAME }}' does not comply with naming convention vX.Y.Z" exit 1 fi - name: Set version number with v + id: set-version-number run: | - echo "VERSION_NUMBER=$(echo ${{ github.event.inputs.tag_name }})" >> $GITHUB_ENV + echo "version_number=$(echo ${{ env.TAG_NAME }})" >> $GITHUB_OUTPUT - name: Set major tag with v + id: set-major-tag run: | - echo "MAJOR_TAG=$(echo ${{ env.VERSION_NUMBER }} | cut -d. -f1)" >> $GITHUB_ENV + echo "major_tag=$(echo ${{ steps.set-version-number.outputs.version_number }} | cut -d. -f1)" >> $GITHUB_OUTPUT - name: Clone sources uses: actions/checkout@v4 - - name: Check version ${{ env.VERSION_NUMBER }} consistency in CHANGELOG and README + - name: Check version consistency in CHANGELOG and README run: | # Check top ## [VERSION_NUMBER](GITHUB_URL/releases/tag/VERSION_NUMBER) - yyyy-mm-dd in CHANGELOG.md CURRENT_DATE=$(date +'%Y-%m-%d') CHANGELOG_VERSION=$(grep -o -E "## \[(.*)\].* - $CURRENT_DATE" CHANGELOG.md | head -1 | sed 's/ //g') - if [[ $CHANGELOG_VERSION == "##[${{ env.VERSION_NUMBER }}]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/${{ env.VERSION_NUMBER }})-$CURRENT_DATE" ]] + if [[ $CHANGELOG_VERSION == "##[${{ steps.set-version-number.outputs.version_number }}]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/${{ steps.set-version-number.outputs.version_number }})-$CURRENT_DATE" ]] then echo "CHANGELOG VERSION OK" else @@ -60,26 +59,23 @@ jobs: fi # Check top [_Compare with previous release_](GITHUB_URL/compare/vLAST_TAG...VERSION_NUMBER) in CHANGELOG.md - if [[ ${{ github.event.inputs.first-release }} != "true" ]] + COMPARISON=$(grep -oP "\/compare\/\K(.*)$" CHANGELOG.md | head -1) + LAST_TAG=$(curl -Ls -o /dev/null -w %{url_effective} $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/latest | grep -oP "\/tag\/\K(.*)$") + if [[ $COMPARISON == "$LAST_TAG...${{ steps.set-version-number.outputs.version_number }})" ]] then - COMPARISON=$(grep -oP "\/compare\/\K(.*)$" CHANGELOG.md | head -1) - LAST_TAG=$(curl -Ls -o /dev/null -w %{url_effective} $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/latest | grep -oP "\/tag\/\K(.*)$") - if [[ $COMPARISON == "$LAST_TAG...${{ env.VERSION_NUMBER }})" ]] - then - echo "VERSION COMPARISON OK" - else - echo "VERSION COMPARISON KO" - echo $COMPARISON - echo "$LAST_TAG...${{ env.VERSION_NUMBER }})" - exit 1 - fi + echo "VERSION COMPARISON OK" + else + echo "VERSION COMPARISON KO" + echo $COMPARISON + echo "$LAST_TAG...${{ steps.set-version-number.outputs.version_number }})" + exit 1 fi # Check first major tag uses in README README_VERSION=$(grep -E "$GITHUB_REPOSITORY@v(.*)" README.md | sed 's/ //g' | head -1) echo $README_VERSION - echo "-uses:$GITHUB_REPOSITORY@v${{ env.MAJOR_TAG }}" - if [[ $README_VERSION == "-uses:$GITHUB_REPOSITORY@${{ env.MAJOR_TAG }}" ]] + echo "-uses:$GITHUB_REPOSITORY@v${{ steps.set-major-tag.outputs.major_tag }}" + if [[ $README_VERSION == "-uses:$GITHUB_REPOSITORY@${{ steps.set-major-tag.outputs.major_tag }}" ]] then echo "Major tag in README.md: OK" else @@ -90,8 +86,8 @@ jobs: # Check second major tags uses in README README_VERSION=$(grep -E "$GITHUB_REPOSITORY@v(.*)" README.md | sed 's/ //g' | tail -1) echo $README_VERSION - echo "-uses:$GITHUB_REPOSITORY@v${{ env.MAJOR_TAG }}" - if [[ $README_VERSION == "-uses:$GITHUB_REPOSITORY@${{ env.MAJOR_TAG }}" ]] + echo "-uses:$GITHUB_REPOSITORY@v${{ steps.set-major-tag.outputs.major_tag }}" + if [[ $README_VERSION == "-uses:$GITHUB_REPOSITORY@${{ steps.set-major-tag.outputs.major_tag }}" ]] then echo "Major tag in README.md: OK" else @@ -99,7 +95,7 @@ jobs: exit 1 fi - - name: Create Tag ${{ github.event.inputs.tag_name }} + - name: Create Tag uses: actions/github-script@v7 with: github-token: ${{ github.token }} @@ -107,31 +103,25 @@ jobs: github.rest.git.createRef({ owner: context.repo.owner, repo: context.repo.repo, - ref: "refs/tags/${{ github.event.inputs.tag_name }}", + ref: "refs/tags/${{ env.TAG_NAME }}", sha: context.sha }) - name: Prepare release notes run: | # Retrieve release body and remove --- - VERSION_RELEASE_NOTES=$(awk -v ver="[${{ env.VERSION_NUMBER }}]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/${{ env.VERSION_NUMBER }})" '/^## / { if (p) { exit }; if ($2 == ver) { p=1; next} } p && NF' CHANGELOG.md | sed ':a;N;$!ba;s/\n---/ /g') + VERSION_RELEASE_NOTES=$(awk -v ver="[${{ steps.set-version-number.outputs.version_number }}]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/${{ steps.set-version-number.outputs.version_number }})" '/^## / { if (p) { exit }; if ($2 == ver) { p=1; next} } p && NF' CHANGELOG.md | sed ':a;N;$!ba;s/\n---/ /g') echo "$VERSION_RELEASE_NOTES" >> CHANGELOG.txt - - name: Create release ${{ env.VERSION_NUMBER }} - uses: softprops/action-gh-release@v1 + - name: Create release ${{ steps.set-version-number.outputs.version_number }} + uses: softprops/action-gh-release@v2 with: body_path: CHANGELOG.txt - name: ${{ env.VERSION_NUMBER }} - tag_name: ${{ github.event.inputs.tag_name }} + name: ${{ steps.set-version-number.outputs.version_number }} + tag_name: ${{ env.TAG_NAME }} draft: false prerelease: false - - name: Set outputs - id: set-outputs - run: | - echo "version_number=${{ env.VERSION_NUMBER }}" >> $GITHUB_OUTPUT - echo "major_tag=${{ env.MAJOR_TAG }}" >> $GITHUB_OUTPUT - update-major-tag: name: Update major tag runs-on: ubuntu-latest @@ -149,3 +139,10 @@ jobs: - name: Push the major tag run: git push origin ${{ needs.create-release.outputs.major_tag }} --force + + run-test: + name: Run test on add-ons + needs: [create-release, update-major-tag] + uses: ./.github/workflows/add-ons-test.yml + with: + action_ref: ${{ needs.create-release.outputs.major_tag }} diff --git a/CHANGELOG.md b/CHANGELOG.md index c20d78d..d3182b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,14 +11,88 @@ The [public API](https://semver.org/spec/v2.0.0.html#spec-item-1) of this projec --- +## [v2.3.2](https://github.com/ddev/github-action-add-on-test/releases/tag/v2.3.2) - 2025-04-22 + +[_Compare with previous release_](https://github.com/ddev/github-action-add-on-test/compare/v2.3.1...v2.3.2) + +### Fixed + +- Synchronize the major tag with the correct commit + + +## [v2.3.1](https://github.com/ddev/github-action-add-on-test/releases/tag/v2.3.1) - 2025-04-22 + +[_Compare with previous release_](https://github.com/ddev/github-action-add-on-test/compare/v2.3.0...v2.3.1) + +### Fixed + +- Remove "Keep alive" feature as [related repository](https://github.com/gautamkrishnar/keepalive-workflow) has been + disabled and causes the action to fail ([PR #43](https://github.com/ddev/github-action-add-on-test/pull/43)) + +--- + +## [v2.3.0](https://github.com/ddev/github-action-add-on-test/releases/tag/v2.3.0) - 2024-10-29 + +[_Compare with previous release_](https://github.com/ddev/github-action-add-on-test/compare/v2.2.0...v2.3.0) + +### Changed + +- Exclude "release" tagged tests for _push_ workflow ([PR #38](https://github.com/ddev/github-action-add-on-test/pull/38)) + +--- + +## [v2.2.0](https://github.com/ddev/github-action-add-on-test/releases/tag/v2.2.0) - 2024-10-15 + +[_Compare with previous release_](https://github.com/ddev/github-action-add-on-test/compare/v2.1.0...v2.2.0) + +### Changed + +- Quiet down the `brew` installs ([PR #35](https://github.com/ddev/github-action-add-on-test/pull/35)) + +--- + +## [v2.1.0](https://github.com/ddev/github-action-add-on-test/releases/tag/v2.1.0) - 2024-10-02 + +[_Compare with previous release_](https://github.com/ddev/github-action-add-on-test/compare/v2.0.2...v2.1.0) + +### Changed + +- Exclude "release" tagged tests for _pull request_ workflow ([PR #34](https://github.com/ddev/github-action-add-on-test/pull/34)) + +### Added + +- Add `test_command` input ([PR #34](https://github.com/ddev/github-action-add-on-test/pull/34)) + +--- + +## [v2.0.2](https://github.com/ddev/github-action-add-on-test/releases/tag/v2.0.2) - 2024-05-25 + +[_Compare with previous release_](https://github.com/ddev/github-action-add-on-test/compare/v2.0.1...v2.0.2) + +### Fixed + +- Run keepalive step only for scheduled run ([PR #33](https://github.com/ddev/github-action-add-on-test/pull/33)) + +--- + +## [v2.0.1](https://github.com/ddev/github-action-add-on-test/releases/tag/v2.0.1) - 2024-05-22 + +[_Compare with previous release_](https://github.com/ddev/github-action-add-on-test/compare/v2.0.0...v2.0.1) + +### Fixed + +- Shorten the default `keepalive_time_elapsed` value to `"0"` day ([PR #31](https://github.com/ddev/github-action-add-on-test/pull/31)) + +--- + ## [v2.0.0](https://github.com/ddev/github-action-add-on-test/releases/tag/v2.0.0) - 2024-03-15 [_Compare with previous release_](https://github.com/ddev/github-action-add-on-test/compare/v1.2.0...v2.0.0) ### Changed -- **Breaking change**: Use `gautamkrishnar/keepalive-workflow@v2` to avoid dummy commit. This change requires - modifying permission from `content: write` to `actions: write` in the main workflow. +- **Breaking change**: Use `gautamkrishnar/keepalive-workflow@v2` to avoid dummy commit. This change requires + modifying permission from `contents: write` to `actions: write` in the main workflow. --- diff --git a/README.md b/README.md index a27a9da..eaf953e 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,26 @@ # DDEV add-on test action --- + > A GitHub action to run tests on a DDEV add-on. + --- [![Version](https://img.shields.io/github/v/release/ddev/github-action-add-on-test)](https://github.com/ddev/github-action-add-on-test/releases) -![project is maintained](https://img.shields.io/maintenance/yes/2024.svg) +[![last commit](https://img.shields.io/github/last-commit/ddev/github-action-add-on-test)](https://github.com/ddev/github-action-add-on-test/commits) [![tests](https://github.com/ddev/github-action-add-on-test/actions/workflows/add-ons-test.yml/badge.svg)](https://github.com/ddev/github-action-add-on-test/actions/workflows/add-ons-test.yml) +**Table of Contents** -**Table of Contents** - [Quick start](#quick-start) - [Inputs](#inputs) - [Available keys](#available-keys) - [Usage](#usage) - [Test your DDEV add-on](#test-your-ddev-add-on) + - [`bats` tags and the `test_command` input](#bats-tags-and-the-test_command-input) - [License](#license) - [Contribute](#contribute) @@ -44,12 +47,12 @@ This step will install the latest stable version of DDEV and run `bats tests` co ## Inputs - ### Available keys The following keys are available as `step.with` keys: --- + - `ddev_version` (_String_) DDEV version that will be installed before your tests. @@ -74,14 +77,13 @@ Example: `${{ secrets.GITHUB_TOKEN }}`. - `addon_repository`(_String_) -GitHub repository of the tested addon (`{owner}/{repo}`). Will be used as the `repository` key during a [checkout +GitHub repository of the tested addon (`{owner}/{repo}`). Will be used as the `repository` key during a [checkout action](https://github.com/actions/checkout#usage) Required. Example: `${{ env.GITHUB_REPOSITORY }}`. - --- - `addon_ref`(_String_) @@ -96,7 +98,7 @@ Example: `${{ env.GITHUB_REF }}`. - `addon_path`(_String_) -Path (relative to `$GITHUB_WORKSPACE` ) where the addon will be cloned by a checkout action. Will be used as the `path` +Path (relative to `$GITHUB_WORKSPACE` ) where the addon will be cloned by a checkout action. Will be used as the `path` key of the [checkout action](https://github.com/actions/checkout#usage) Not required. @@ -105,56 +107,37 @@ Default: `./` --- -- `keepalive` (_Boolean_) - -Keeps GitHub from turning off tests after 60 days. - -If enabled, action will use [keepalive-workflow action](https://github.com/gautamkrishnar/keepalive-workflow) when `ddev_version` has been set to `stable`. - -**N.B.** If enabled, you have to update the permission of the main workflow to `write`: +- `debug_enabled` (_Boolean_) -```yaml -permissions: - actions: write -``` +If `true`, a tmate session will be accessible before the tests step. See [action-tmate](https://github.com/mxschmitt/action-tmate) for more details. Not required. -Default: `true`. +Default: `false`. --- +- `disable_checkout_action` (_Boolean_) -- `keepalive_time_elapsed` (_String_) - -Time elapsed from the previous commit to trigger a new automated commit (in days). - -Will be used as the `time_elapsed` key of the [keepalive-workflow action](https://github.com/gautamkrishnar/keepalive-workflow). +If you need to check out your add-on source code with some specific inputs (`submodules`, `ssh-key`, etc.), or you need to perform some extra steps between checkout and DDEV installation steps, you can disable the default checkout action by setting `true` for this input. Not required. -Default: `55`. +Default: `false`. --- +- `test_command` (_String_) -- `debug_enabled` (_Boolean_) +If you want to run a customized test command, you can use this input. -If `true`, a tmate session will be accessible before the tests step. See [action-tmate](https://github.com/mxschmitt/action-tmate) for more details. +If it's empty, the test command will be `bats tests --filter-tags !release` during _push_ or _pull request_ workflows and `bats tests` otherwise. Not required. -Default: `false`. +Default: `""`. ---- - -- `disable_checkout_action` (_Boolean_) - -If you need to check out your add-on source code with some specific inputs (`submodules`, `ssh-key`, etc.), or you need to perform some extra steps between checkout and DDEV installation steps, you can disable the default checkout action by setting `true` for this input. - -Not required. - -Default: `false`. +For more details, see [below](#bats-tags-and-the-test_command-input). --- @@ -162,23 +145,22 @@ Default: `false`. ### Test your DDEV add-on -If your add-on is based on the [DDEV add-on template repository](https://github.com/ddev/ddev-addon-template), you +If your add-on is based on the [DDEV add-on template repository](https://github.com/ddev/ddev-addon-template), you should have a tests folder containing a `test.bats` file. -Using this GitHub action, a `.github/workflows/tests.yml` file could have the following content: - +Using this GitHub action, a `.github/workflows/tests.yml` file could have the following content: ```yaml name: tests on: pull_request: push: - branches: [ main ] + branches: [main] paths-ignore: - - '**.md' + - "**.md" schedule: - - cron: '25 08 * * *' + - cron: "25 08 * * *" workflow_dispatch: inputs: @@ -188,11 +170,10 @@ on: default: false permissions: - actions: write + contents: read jobs: tests: - strategy: matrix: ddev_version: [stable, HEAD] @@ -201,16 +182,68 @@ jobs: runs-on: ubuntu-latest steps: + - uses: ddev/github-action-add-on-test@v2 + with: + ddev_version: ${{ matrix.ddev_version }} + token: ${{ secrets.GITHUB_TOKEN }} + debug_enabled: ${{ github.event.inputs.debug_enabled }} + addon_repository: ${{ env.GITHUB_REPOSITORY }} + addon_ref: ${{ env.GITHUB_REF }} +``` + +#### `bats` tags and the `test_command` input - - uses: ddev/github-action-add-on-test@v2 - with: - ddev_version: ${{ matrix.ddev_version }} - token: ${{ secrets.GITHUB_TOKEN }} - debug_enabled: ${{ github.event.inputs.debug_enabled }} - addon_repository: ${{ env.GITHUB_REPOSITORY }} - addon_ref: ${{ env.GITHUB_REF }} +By default, this GitHub action is configured to exclude `release` tagged tests during _push_ and +_pull_request_ workflows by using the `bats tests --filter-tags '!release'` command. + +For other workflows, the default command is `bats tests`, meaning all tests, regardless of their tags, will run. + +To tag a test with a `release` tag, add `# bats test_tags=release` above the `@test` line in your bats file: + +```bash +# bats test_tags=release +@test "install from release" { + ... + + ... +} ``` +This setup keeps release-specific tests out of everyday workflows unless you set a custom `test_command`. + +For more information on `bats` tags and filtering tests by tags, refer to the [bats documentation](https://bats-core.readthedocs.io/en/stable/writing-tests.html#tagging-tests). + +#### Preserving Artifacts + +GitHub Actions provides a UI for browsing test artifacts. To use it, store `$TESTDIR` in `$GITHUB_ENV` within your Bats tests (see [example](https://github.com/ddev/ddev-addon-template/blob/main/tests/test.bats)), and configure your job as follows: + +```yaml +jobs: + tests: + steps: + ... + + # Optionally, you may need to zip some artifacts before uploading them + # to fix this error: "The path for one of the files in artifact is not valid" + # - name: Zip artifacts that can't be processed by actions/upload-artifact + # if: always() + # run: | + # for d in ${{ env.TESTDIR }}*/; do + # if [ -d "$d/path/to/directory" ]; then + # (cd "$d/path/to" && zip -r directory.zip directory) + # fi + # done + + - name: Upload artifacts + if: always() + uses: actions/upload-artifact@v4 + with: + name: artifact-${{ matrix.ddev_version }} + path: | + ${{ env.TESTDIR }}*/tests + ${{ env.TESTDIR }}*/web/*.junit.xml + ${{ env.TESTDIR }}*/path/to/directory.zip +``` ## License @@ -220,5 +253,6 @@ jobs: Anyone is welcome to submit a pull request to this repository. +For more details on development processes, please read the [developer guide](./docs/DEVELOPER.md). **Contributed and maintained by [julienloizelet](https://github.com/julienloizelet)** diff --git a/action.yaml b/action.yaml index 4473e66..1469bed 100644 --- a/action.yaml +++ b/action.yaml @@ -3,7 +3,6 @@ author: "Julien Loizelet" description: "A Github Action to run DDEV add-on tests" inputs: - ddev_version: type: choice required: false @@ -14,57 +13,50 @@ inputs: - "HEAD" addon_repository: - description: 'Repository of the tested addon' + description: "Repository of the tested addon" required: true addon_ref: - description: 'Repository ref of the tested addon' + description: "Repository ref of the tested addon" required: true addon_path: - description: 'Path to clone the addon' - required: false - default: './' - - keepalive: - type: boolean - description: 'Keeps GitHub from turning off tests after 60 days' + description: "Path to clone the addon" required: false - default: true - - keepalive_time_elapsed: - description: 'Time elapsed from the previous commit to trigger a new automated commit (in days)' - required: false - default: 55 + default: "./" debug_enabled: type: boolean - description: Debug with tmate + description: "Debug with tmate" required: false default: false disable_checkout_action: type: boolean - description: Disable addon checkout action + description: "Disable addon checkout action" required: false default: false token: - description: 'A Github PAT' + description: "A Github PAT" required: true + test_command: + description: "Test command to run" + required: false + default: "" + runs: using: "composite" steps: - - - uses: Homebrew/actions/setup-homebrew@master + - uses: Homebrew/actions/setup-homebrew@main - name: Environment setup shell: bash run: | # For bats-assert and friends - brew tap kaos/shell - brew install bats-core bats-file bats-assert bats-support jq mkcert yq + brew tap bats-core/bats-core >/dev/null + brew install bats-core bats-file bats-assert bats-support jq mkcert yq >/dev/null mkcert -install - uses: actions/checkout@v4 @@ -77,12 +69,12 @@ runs: - name: Use ddev stable shell: bash if: inputs.ddev_version == 'stable' - run: brew install ddev/ddev/ddev + run: brew install ddev/ddev/ddev >/dev/null - name: Use ddev HEAD shell: bash if: inputs.ddev_version == 'HEAD' - run: brew install --HEAD ddev/ddev/ddev + run: brew install --HEAD ddev/ddev/ddev >/dev/null - name: Download docker images shell: bash @@ -102,15 +94,30 @@ runs: DDEV_NONINTERACTIVE: "true" # Don't send telemetry to amplitude DDEV_NO_INSTRUMENTATION: "true" - + # Use test_command input if provided + TEST_COMMAND_INPUT: ${{ inputs.test_command }} + # Use the addon path + ADDON_PATH: ${{ inputs.addon_path }} + # Use the event name + GITHUB_EVENT_NAME: ${{ github.event_name }} shell: bash - run: cd ${{ inputs.addon_path }} && bats tests - - # keepalive-workflow keeps GitHub from turning off tests after 60 days - - uses: gautamkrishnar/keepalive-workflow@v2 - if: always() && matrix.ddev_version == 'stable' && inputs.keepalive == 'true' - with: - time_elapsed: ${{ inputs.keepalive_time_elapsed }} + # Use of "set +H" to ensure that bash history expansion is disabled so that ! can be used in test command + run: | + set +H + if [ -n "$TEST_COMMAND_INPUT" ]; then + TEST_COMMAND="$TEST_COMMAND_INPUT" + else + case "$GITHUB_EVENT_NAME" in + "push"|"pull_request") + TEST_COMMAND="bats tests --filter-tags !release" + ;; + *) + TEST_COMMAND="bats tests" + ;; + esac + fi + echo "Running: $TEST_COMMAND in $ADDON_PATH" + cd $ADDON_PATH && $TEST_COMMAND branding: icon: "code" diff --git a/docs/DEVELOPER.md b/docs/DEVELOPER.md new file mode 100644 index 0000000..790c205 --- /dev/null +++ b/docs/DEVELOPER.md @@ -0,0 +1,91 @@ +# DDEV add-on test action + +## Developer guide + +**Table of Contents** + + + + +- [Commit message](#commit-message) + - [Allowed message `type` values](#allowed-message-type-values) + - [Squash and merge pull request](#squash-and-merge-pull-request) +- [Update documentation table of contents](#update-documentation-table-of-contents) +- [Release process](#release-process) + + + +## Commit message + +This is not formally required, but in order to have an explicit commit history, we use some commits message convention with the following format: + + (): + +Allowed `type` are defined below. +`scope` value intends to clarify which part of the code has been modified. It can be empty or `*` if the change is a +global or difficult to assign to a specific part. +`subject` describes what has been done using the imperative, present tense. + +Example: + + feat(logger): Add a new property for logger + +### Allowed message `type` values + +- chore (automatic tasks; no production code change) +- ci (updating continuous integration process; no production code change) +- comment (commenting;no production code change) +- docs (changes to the documentation) +- feat (new feature for the user) +- fix (bug fix for the user) +- refactor (refactoring production code) +- style (formatting; no production code change) +- test (adding missing tests, refactoring tests; no production code change) + +### Squash and merge pull request + +Please note that if you merge a pull request in GitHub using the "squash and merge" option (recommended), the pull request title will be used as the commit message for the squashed commit. + +You should ensure that the resulting commit message is valid with respect to the above convention. + +## Update documentation table of contents + +To update the table of contents in the documentation, you can use [the `doctoc` tool](https://github.com/thlorenz/doctoc). + +First, install it: + +```bash +npm install -g doctoc +``` + +Then, run it in the root folder: + +```bash +doctoc README.md --maxlevel 4 && doctoc docs/* --maxlevel 4 +``` + +## Release process + +We are using [semantic versioning](https://semver.org/) to determine a version number. To verify the current tag, +you should run: + +``` +git describe --tags `git rev-list --tags --max-count=1` +``` + +Before publishing a new release, there are some manual steps to take: + +- Update the `CHANGELOG.md` file to the current format. The release description is based on the contents of the `CHANGELOG.md` file. +- If the release is a major release, modify the major tag in the `README.md` file wherever necessary. + +Then, you have to [run the action manually using `Actions -> Create Release -> Tag Name`](https://github.com/ddev/github-action-add-on-test/actions/workflows/release.yml). + +Alternatively, you could use the [GitHub CLI](https://github.com/cli/cli): + +- publish a release: + +``` +gh workflow run release.yml -f tag_name=vx.y.z +``` + +Note that the GitHub action will fail if the tag `tag_name` already exits.