diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..77f3fb2 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,15 @@ +name: Lint + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + actionlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run actionlint + uses: docker://rhysd/actionlint:latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e9a3c26 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,72 @@ +name: Test Solidus Extension + +on: + workflow_call: + inputs: + rails_versions: + description: 'Rails versions to test (JSON array)' + type: string + default: '["8.0", "7.2"]' + ruby_versions: + description: 'Ruby versions to test (JSON array)' + type: string + default: '["3.4"]' + solidus_branches: + description: 'Solidus branches to test (JSON array)' + type: string + default: '["v4.6", "v4.5"]' + databases: + description: 'Databases to test (JSON array): postgresql, mysql, sqlite' + type: string + default: '["postgresql", "mysql", "sqlite"]' + +jobs: + Extension: + name: Solidus ${{ matrix.solidus_branch }}, Rails ${{ matrix.rails_version }} and Ruby ${{ matrix.ruby_version }} on ${{ matrix.database }} + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + rails_version: ${{ fromJSON(inputs.rails_versions) }} + ruby_version: ${{ fromJSON(inputs.ruby_versions) }} + solidus_branch: ${{ fromJSON(inputs.solidus_branches) }} + database: ${{ fromJSON(inputs.databases) }} + exclude: + - solidus_branch: "v4.5" + ruby_version: "3.1" + - solidus_branch: "v4.6" + ruby_version: "3.1" + - solidus_branch: "v4.4" + rails_version: "8.0" + services: + postgres: + image: postgres:16 + env: + POSTGRES_HOST_AUTH_METHOD: trust + options: >- + --health-cmd="pg_isready" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + ports: + - 5432:5432 + mysql: + image: mysql:8 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: "yes" + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + ports: + - 3306:3306 + steps: + - uses: actions/checkout@v4 + - name: Run extension tests + uses: solidusio/test-solidus-extension@support-testings-dbs + with: + database: ${{ matrix.database }} + rails-version: ${{ matrix.rails_version }} + ruby-version: ${{ matrix.ruby_version }} + solidus-branch: ${{ matrix.solidus_branch }} diff --git a/README.md b/README.md index da68bbe..18d1451 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,53 @@ # Test Solidus Extension GitHub action -A GitHub action for testing Solidus extensions +GitHub actions and workflows for testing Solidus extensions. -## Inputs +## Usage + +### Reusable Workflow (Recommended) + +The simplest way to test your extension. The reusable workflow handles database services and provides a sensible default test matrix: + +```yaml +name: Test + +on: + push: + branches: [main] + pull_request: + +jobs: + Test: + uses: solidusio/test-solidus-extension/.github/workflows/test.yml@main +``` + +#### Inputs + +| Input | Description | Default | +|-------|-------------|---------| +| `rails_versions` | Rails versions (JSON array) | `["8.0", "7.2"]` | +| `ruby_versions` | Ruby versions (JSON array) | `["3.4"]` | +| `solidus_branches` | Solidus branches (JSON array) | `["v4.6", "v4.5"]` | +| `databases` | Databases (JSON array) | `["postgresql", "mysql", "sqlite"]` | + +#### Custom Matrix + +Override any input to customize the test matrix: + +```yaml +jobs: + test: + uses: solidusio/test-solidus-extension/.github/workflows/test.yml@main + with: + rails_versions: '["7.2"]' + databases: '["postgresql", "sqlite"]' +``` + +### Composite Action + +For full control over your workflow, use the composite action directly. This requires you to define database services yourself. + +#### Inputs | Input | Description | Required | Default | |-------|-------------|----------|---------| @@ -11,13 +56,13 @@ A GitHub action for testing Solidus extensions | `solidus-branch` | Solidus branch to use | Yes | `main` | | `database` | Database to use (`sqlite`, `postgresql`, `mysql`, or `mariadb`) | Yes | `sqlite` | -## Database Services +#### Database Services -This is a composite GitHub Action, which means it **cannot define services directly**. If you need to test against PostgreSQL or MySQL/MariaDB, you must define the database service in your workflow file. +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. The action will install the necessary database client libraries automatically based on the `database` input. -### Database Credentials +#### Database Credentials The action automatically sets the correct `DB_USERNAME` based on the database: @@ -26,10 +71,7 @@ The action automatically sets the correct `DB_USERNAME` based on the database: Configure your database services with passwordless access for simplicity (see example below). -> [!WARNING] -> 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. - -## Example configuration +#### Example Configuration ```yaml name: Test