|
| 1 | +name: "Test Solidus" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + lib_name: |
| 7 | + description: "The name of the Solidus library to test (e.g., core, backend, frontend)" |
| 8 | + type: string |
| 9 | + required: true |
| 10 | + coverage: |
| 11 | + description: "Enable code coverage reporting" |
| 12 | + type: boolean |
| 13 | + default: false |
| 14 | + |
| 15 | +jobs: |
| 16 | + RSpec: |
| 17 | + name: Rails ${{ matrix.rails }}, Ruby ${{ matrix.ruby }}, ${{ matrix.database }}, ${{ matrix.storage }} |
| 18 | + runs-on: ubuntu-22.04 |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + include: |
| 23 | + - rails: "7.0" |
| 24 | + ruby: "3.1" |
| 25 | + database: postgres |
| 26 | + storage: paperclip |
| 27 | + - rails: "7.1" |
| 28 | + ruby: "3.2" |
| 29 | + database: mysql |
| 30 | + storage: activestorage |
| 31 | + - rails: "7.2" |
| 32 | + ruby: "3.3" |
| 33 | + database: postgres |
| 34 | + storage: activestorage |
| 35 | + - rails: "8.0" |
| 36 | + ruby: "3.4" |
| 37 | + database: sqlite |
| 38 | + storage: activestorage |
| 39 | + env: |
| 40 | + BUNDLE_WITHOUT: "lint release" |
| 41 | + COVERAGE: ${{ inputs.coverage }} |
| 42 | + COVERAGE_DIR: tmp/coverage |
| 43 | + DB: ${{ matrix.database }} |
| 44 | + DB_HOST: "127.0.0.1" |
| 45 | + DB_USERNAME: solidus |
| 46 | + DB_PASSWORD: password |
| 47 | + DEFAULT_MAX_WAIT_TIME: 10 |
| 48 | + DISABLE_ACTIVE_STORAGE: ${{ matrix.storage == 'paperclip' }} |
| 49 | + LIB_NAME: ${{ inputs.lib_name }} |
| 50 | + RAILS_ENV: test |
| 51 | + RAILS_VERSION: '~> ${{ matrix.rails }}' |
| 52 | + SOLIDUS_RAISE_DEPRECATIONS: true |
| 53 | + services: |
| 54 | + postgres: |
| 55 | + image: postgres:13 |
| 56 | + env: |
| 57 | + POSTGRES_USER: ${{ env.DB_USERNAME }} |
| 58 | + POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }} |
| 59 | + POSTGRES_DB: solidus_${{ inputs.lib_name }}_test |
| 60 | + ports: [5432:5432] |
| 61 | + options: >- |
| 62 | + --health-cmd pg_isready |
| 63 | + --health-interval 10s |
| 64 | + --health-timeout 5s |
| 65 | + --health-retries 5 |
| 66 | + mysql: |
| 67 | + image: mysql:5.7 |
| 68 | + env: |
| 69 | + MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }} |
| 70 | + MYSQL_PASSWORD: ${{ env.DB_PASSWORD }} |
| 71 | + MYSQL_USER: ${{ env.DB_USERNAME }} |
| 72 | + MYSQL_DATABASE: solidus_${{ inputs.lib_name }}_test |
| 73 | + ports: [3306:3306] |
| 74 | + options: >- |
| 75 | + --health-cmd "mysqladmin ping -h 127.0.0.1 -uroot -proot" |
| 76 | + --health-interval 10s |
| 77 | + --health-timeout 5s |
| 78 | + --health-retries 5 |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + - name: Setup Ruby |
| 82 | + uses: ruby/setup-ruby@v1 |
| 83 | + with: |
| 84 | + ruby-version: ${{ matrix.ruby }} |
| 85 | + bundler-cache: true |
| 86 | + - uses: awalsh128/cache-apt-pkgs-action@v1 |
| 87 | + if: ${{ matrix.storage == 'activestorage' }} |
| 88 | + name: Install libvips |
| 89 | + with: |
| 90 | + packages: libvips-dev |
| 91 | + - name: Run tests |
| 92 | + run: | |
| 93 | + cd ${{ inputs.lib_name }} |
| 94 | + bundle exec rake test_app |
| 95 | + bundle exec rspec --profile 10 --format progress |
| 96 | +
|
| 97 | + Coverage: |
| 98 | + runs-on: ubuntu-latest |
| 99 | + if: ${{ inputs.coverage == 'true' }} |
| 100 | + needs: |
| 101 | + - RSpec |
| 102 | + steps: |
| 103 | + - name: Report Coverage |
| 104 | + run: | |
| 105 | + bundle exec rake solidus:coverage[cobertura] |
| 106 | + - name: Upload Coverage Report |
| 107 | + uses: actions/upload-artifact@v4 |
| 108 | + with: |
| 109 | + name: coverage-report |
| 110 | + path: tmp/coverage/coverage.xml |
0 commit comments