Skip to content

Commit

Permalink
feat(*): Add tmate and run test steps in actions (#5)
Browse files Browse the repository at this point in the history
* feat(*): Put all steps in the action

* feat(*): Prepare release v0.2.0

* feat(*): Remove keepalive action as it does not work here

* feat(*): Rename action
  • Loading branch information
julienloizelet authored Aug 10, 2023
1 parent 8000754 commit d47b8a9
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 41 deletions.
27 changes: 15 additions & 12 deletions .github/workflows/add-on-simple-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ on:
push:
branches:
- main
- feat/add-sub-actions
paths-ignore:
- '**.md'
schedule:
- cron: '25 08 * * *'
workflow_dispatch:

permissions:
contents: read
contents: write

env:
# Allow ddev get to use a GitHub token to prevent rate limiting by tests
Expand All @@ -21,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ddev_version: [ stable, HEAD, edge ]
ddev_version: [ stable, HEAD ]

name: Add-on simple tests
runs-on: ubuntu-20.04
Expand All @@ -31,20 +32,22 @@ jobs:

steps:

- name: Clone tested add-on files
uses: actions/checkout@v3
with:
repository: ${{ env.ADDON_GITHUB_URL }}
ref: ${{ env.ADDON_REF }}

- name: Clone current repository
uses: actions/checkout@v3
with:
path: action

- name: Install DDEV (${{ matrix.ddev_version }})
uses: ./
- name: Run DDEV test (${{ matrix.ddev_version }})
uses: ./action/
with:
ddev_version: ${{ matrix.ddev_version }}
token: ${{ secrets.GITHUB_TOKEN }}
debug_enabled: false

- name: Clone add-on files
uses: actions/checkout@v3
with:
path: tested-add-on
repository: ${{ env.ADDON_GITHUB_URL }}
ref: ${{ env.ADDON_REF }}

- name: Run test
run: cd tested-add-on && bats tests
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,28 @@ The [public API](https://semver.org/spec/v2.0.0.html#spec-item-1) of this projec


---
## [v0.1.0](https://github.com/julienloizelet/ddev-add-on-test-init/releases/tag/v0.1.0) - 2023-08-07
[_Compare with previous release_](https://github.com/julienloizelet/ddev-add-on-test-init/compare/v0.0.1...v0.1.0)

## [v0.2.0](https://github.com/julienloizelet/ddev-add-on-test/releases/tag/v0.1.0) - 2023-08-10
[_Compare with previous release_](https://github.com/julienloizelet/ddev-add-on-test/compare/v0.1.0...v0.2.0)

### Removed

- Remove `edge` for `ddev_version` input instead of a free string

### Added

- Add `mxschmitt/action-tmate` and `Run test` steps in the action


## [v0.1.0](https://github.com/julienloizelet/ddev-add-on-test/releases/tag/v0.1.0) - 2023-08-07
[_Compare with previous release_](https://github.com/julienloizelet/ddev-add-on-test/compare/v0.0.1...v0.1.0)

### Changed

- Use choice (`stable`, `edge`, `HEAD`) for `ddev_version` input instead of a free string

---
## [v0.0.1](https://github.com/julienloizelet/ddev-add-on-test-init/releases/tag/v0.0.1) - 2023-07-10
## [v0.0.1](https://github.com/julienloizelet/ddev-add-on-test/releases/tag/v0.0.1) - 2023-07-10

### Added
- Initial release
46 changes: 30 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ _We will suppose here that you want to test your add-on with the stable version
You can add the following step in your workflow:

```yaml
- uses: julienloizelet/ddev-add-on-test-init@v0.1.0
- uses: julienloizelet/ddev-add-on-test@v0.2.0
with:
ddev_version: "stable"
```
Expand All @@ -49,7 +49,27 @@ DDEV version that will be installed before your tests.

Default: `stable`.

Allowed values are: `stable`, `HEAD`, `edge`.
Allowed values are: `stable`, `HEAD`.

---

- `debug_enabled`

If `true`, a tmate session will be accessible before the tests step. See [action-tmate](https://github.com/mxschmitt/action-tmate) for more details.


Default: `false`.

---


- `token` (_String_)

A GitHub PAT required for the debug step.

A simple value could be: `${{ secrets.GITHUB_TOKEN }}`.

---


## Usage
Expand Down Expand Up @@ -105,22 +125,16 @@ jobs:
- uses: actions/checkout@v3
- uses: julienloizelet/[email protected]
with:
ddev_version: ${{ matrix.ddev_version }}
- name: tmate debugging session
uses: mxschmitt/action-tmate@v3
- uses: julienloizelet/[email protected]
with:
limit-access-to-actor: true
github-token: ${{ secrets.GITHUB_TOKEN }}
if: github.event.inputs.debug_enabled == 'true'
- name: tests
run: bats tests
ddev_version: ${{ matrix.ddev_version }}
token: ${{ secrets.GITHUB_TOKEN }}
debug_enabled: ${{ github.event.inputs.debug_enabled }}
# keepalive-workflow adds a dummy commit if there's no other action here, keeps
# GitHub from turning off tests after 60 days
- uses: gautamkrishnar/keepalive-workflow@v1
if: matrix.ddev_version == 'stable'
if: matrix.ddev_version == 'stable'
```

Expand Down
31 changes: 21 additions & 10 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "DDEV add-on test init"
name: "DDEV add-on test"
author: "Julien Loizelet"
description: "A Github Action to initialize DDEV add-on tests"
description: "A Github Action to run DDEV add-on tests"

inputs:

Expand All @@ -10,9 +10,16 @@ inputs:
default: "stable"
description: "DDEV Version to use"
options:
- stable
- HEAD

- "stable"
- "HEAD"
debug_enabled:
type: boolean
description: Debug with tmate
required: false
default: false
token:
description: 'A Github PAT'
required: true

runs:
using: "composite"
Expand All @@ -31,11 +38,6 @@ runs:
if: inputs.ddev_version == 'stable'
run: brew install ddev/ddev/ddev

- name: Use ddev edge
shell: bash
if: inputs.ddev_version == 'edge'
run: brew install ddev/ddev-edge/ddev

- name: Use ddev HEAD
shell: bash
if: inputs.ddev_version == 'HEAD'
Expand All @@ -45,6 +47,15 @@ runs:
shell: bash
run: ddev debug download-images >/dev/null

- uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
github-token: ${{ inputs.token }}
if: inputs.debug_enabled == 'true'

- name: Run test
shell: bash
run: bats tests

branding:
icon: "code"
Expand Down

0 comments on commit d47b8a9

Please sign in to comment.