|
| 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 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + fail-fast: true |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - rails: "7.1" |
| 23 | + ruby: "3.1" |
| 24 | + database: sqlite |
| 25 | + storage: paperclip |
| 26 | + - rails: "7.2" |
| 27 | + ruby: "3.2" |
| 28 | + database: postgres |
| 29 | + storage: activestorage |
| 30 | + - rails: "8.0" |
| 31 | + ruby: "3.4" |
| 32 | + database: mysql |
| 33 | + storage: paperclip |
| 34 | + env: |
| 35 | + BUNDLE_WITHOUT: "lint release" |
| 36 | + COVERAGE: ${{ inputs.coverage }} |
| 37 | + COVERAGE_DIR: tmp/coverage |
| 38 | + DB: ${{ matrix.database }} |
| 39 | + DB_HOST: ${{ matrix.database == 'mysql' && '127.0.0.1' || 'localhost' }} |
| 40 | + DB_USERNAME: solidus |
| 41 | + DB_PASSWORD: password |
| 42 | + DEFAULT_MAX_WAIT_TIME: 10 |
| 43 | + DISABLE_ACTIVE_STORAGE: ${{ matrix.storage == 'paperclip' }} |
| 44 | + LIB_NAME: ${{ inputs.lib_name }} |
| 45 | + RAILS_ENV: test |
| 46 | + RAILS_VERSION: ${{ matrix.rails }} |
| 47 | + SOLIDUS_RAISE_DEPRECATIONS: true |
| 48 | + services: |
| 49 | + postgres: |
| 50 | + image: postgres:13 |
| 51 | + env: |
| 52 | + POSTGRES_USER: ${{ env.DB_USERNAME }} |
| 53 | + POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }} |
| 54 | + POSTGRES_DB: solidus_test |
| 55 | + ports: [5432:5432] |
| 56 | + options: >- |
| 57 | + --health-cmd pg_isready |
| 58 | + --health-interval 10s |
| 59 | + --health-timeout 5s |
| 60 | + --health-retries 5 |
| 61 | + mysql: |
| 62 | + image: mysql:5.7 |
| 63 | + env: |
| 64 | + MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }} |
| 65 | + MYSQL_DATABASE: solidus_test |
| 66 | + ports: [3306:3306] |
| 67 | + options: >- |
| 68 | + --health-cmd "mysqladmin ping -h 127.0.0.1 -uroot -proot" |
| 69 | + --health-interval 10s |
| 70 | + --health-timeout 5s |
| 71 | + --health-retries 5 |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v4 |
| 74 | + - name: Set up Ruby |
| 75 | + uses: ruby/setup-ruby@v1 |
| 76 | + with: |
| 77 | + ruby-version: ${{ matrix.ruby }} |
| 78 | + bundler-cache: true |
| 79 | + - name: Install imagemagick |
| 80 | + if: ${{ matrix.storage == 'paperclip' }} |
| 81 | + run: | |
| 82 | + sudo apt-get update -yq |
| 83 | + sudo apt-get autoremove -yq |
| 84 | + sudo apt-get install -yq imagemagick --fix-missing |
| 85 | + - name: Install libvips |
| 86 | + if: ${{ matrix.storage == 'activestorage' }} |
| 87 | + run: | |
| 88 | + sudo apt-get update -yq |
| 89 | + sudo apt-get autoremove -yq |
| 90 | + sudo apt-get install -yq libvips-dev --fix-missing |
| 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