Skip to content

Commit

Permalink
feat(*): Put all steps in the action
Browse files Browse the repository at this point in the history
  • Loading branch information
julienloizelet committed Aug 10, 2023
1 parent 8000754 commit adccabb
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 37 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
41 changes: 26 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,29 @@ 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 @@ -107,20 +129,9 @@ jobs:
- uses: julienloizelet/[email protected]
with:
ddev_version: ${{ matrix.ddev_version }}
- name: tmate debugging session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
github-token: ${{ secrets.GITHUB_TOKEN }}
if: github.event.inputs.debug_enabled == 'true'
- name: tests
run: bats tests
- uses: gautamkrishnar/keepalive-workflow@v1
if: matrix.ddev_version == 'stable'
ddev_version: ${{ matrix.ddev_version }}
token: ${{ secrets.GITHUB_TOKEN }}
debug_enabled: false
```

Expand Down
40 changes: 30 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,17 @@ 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
default: ${{ secrets.GITHUB_TOKEN }}

runs:
using: "composite"
Expand All @@ -31,11 +39,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 +48,23 @@ 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

- uses: gautamkrishnar/keepalive-workflow@v1
# keepalive-workflow adds a dummy commit if there's no other action here, keeps
# GitHub from turning off tests after 60 days
with:
commit_message: "chore(*): Automated commit to keep the repository active"
time_elapsed: 1
if: inputs.ddev_version == 'stable'

branding:
icon: "code"
Expand Down

0 comments on commit adccabb

Please sign in to comment.