name: ubuntu

on: [push, pull_request]

jobs:
  build:
    name: build (${{ matrix.ruby }}/${{ matrix.test_mode }})
    strategy:
      matrix:
        ruby: [ '3.3', '3.2', '3.1', '3.0' ]
        test_mode: [ rack, gem ]
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: ${{ matrix.ruby }}
    - uses: niden/actions-memcached@v7
    - run: |
        gem install bundler --no-document -v '2.4.22'
      if: matrix.ruby == '2.7'
    - run: |
        gem update --system --no-document
      if: matrix.ruby != '2.7'
    - name: Install dependencies
      run: |
        echo 'gemspec' > Gemfile.local
        bundle install --without server --jobs=3 --retry=3
        npm install
    - name: Run test
      run: if [ $TEST_MODE = "gem" ] ; then bundle exec tdiary test ; else bundle exec rake spec jasmine:ci test ; fi
      env:
        TEST_MODE: ${{ matrix.test_mode }}
