|
1 | 1 | # Test Solidus Extension GitHub action |
2 | 2 |
|
3 | | -A GitHub action for testing Solidus extensions |
| 3 | +GitHub actions and workflows for testing Solidus extensions. |
4 | 4 |
|
5 | | -## Example configuration |
| 5 | +## Usage |
| 6 | + |
| 7 | +### Reusable Workflow (Recommended) |
| 8 | + |
| 9 | +The simplest way to test your extension. The reusable workflow handles database services and provides a sensible default test matrix: |
| 10 | + |
| 11 | +```yaml |
| 12 | +name: Test |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: [main] |
| 17 | + pull_request: |
| 18 | + |
| 19 | +jobs: |
| 20 | + test: |
| 21 | + uses: solidusio/test-solidus-extension/.github/workflows/test.yml@main |
| 22 | +``` |
| 23 | +
|
| 24 | +#### Inputs |
| 25 | +
|
| 26 | +| Input | Description | Default | |
| 27 | +|-------|-------------|---------| |
| 28 | +| `rails_versions` | Rails versions (JSON array) | `["8.0", "7.2"]` | |
| 29 | +| `ruby_versions` | Ruby versions (JSON array) | `["3.4"]` | |
| 30 | +| `solidus_branches` | Solidus branches (JSON array) | `["v4.6", "v4.5"]` | |
| 31 | +| `databases` | Databases (JSON array) | `["postgresql", "mysql", "sqlite"]` | |
| 32 | + |
| 33 | +#### Custom Matrix |
| 34 | + |
| 35 | +Override any input to customize the test matrix: |
| 36 | + |
| 37 | +```yaml |
| 38 | +jobs: |
| 39 | + test: |
| 40 | + uses: solidusio/test-solidus-extension/.github/workflows/test.yml@main |
| 41 | + with: |
| 42 | + rails_versions: '["7.2"]' |
| 43 | + databases: '["postgresql", "sqlite"]' |
| 44 | +``` |
| 45 | + |
| 46 | +### Composite Action |
| 47 | + |
| 48 | +For full control over your workflow, use the composite action directly. This requires you to define database services yourself. |
| 49 | + |
| 50 | +#### Inputs |
| 51 | + |
| 52 | +| Input | Description | Required | Default | |
| 53 | +|-------|-------------|----------|---------| |
| 54 | +| `ruby-version` | Ruby version to use | Yes | `3.3` | |
| 55 | +| `rails-version` | Rails version to use | Yes | `7.2` | |
| 56 | +| `solidus-branch` | Solidus branch to use | Yes | `main` | |
| 57 | +| `database` | Database to use (`sqlite`, `postgresql`, `mysql`, or `mariadb`) | Yes | `sqlite` | |
| 58 | + |
| 59 | +#### Database Services |
| 60 | + |
| 61 | +The composite GitHub Action **cannot define services directly**. If you need to test against PostgreSQL or MySQL/MariaDB, you must define the database service in your workflow file. |
| 62 | + |
| 63 | +The action will install the necessary database client libraries automatically based on the `database` input. |
| 64 | + |
| 65 | +#### Database Credentials |
| 66 | + |
| 67 | +The action automatically sets the correct `DB_USERNAME` based on the database: |
| 68 | + |
| 69 | +- **PostgreSQL**: `postgres` (default superuser) |
| 70 | +- **MySQL/MariaDB**: `root` (default superuser) |
| 71 | + |
| 72 | +Configure your database services with passwordless access for simplicity (see example below). |
| 73 | + |
| 74 | +> [!WARNING] |
| 75 | +> Rails 8.0 has a [known issue](https://github.com/rails/rails/issues/53673) with MySQL/MariaDB that causes empty `Mysql2::Error` messages. Until a fix is released, exclude the `mariadb` + Rails 8.0 combination from your test matrix. |
| 76 | + |
| 77 | +#### Example Configuration |
6 | 78 |
|
7 | 79 | ```yaml |
8 | 80 | name: Test |
|
0 commit comments