name: 'Rails Lint and Test' on: push: paths-ignore: - 'doc/**' - '**.md' pull_request: paths-ignore: - 'doc/**' - '**.md' defaults: run: working-directory: hitobito jobs: build: runs-on: 'ubuntu-20.04' env: HEADLESS: true RAILS_DB_ADAPTER: mysql2 RAILS_DB_HOST: 127.0.0.1 RAILS_DB_PORT: 33066 RAILS_DB_USERNAME: hitobito RAILS_DB_PASSWORD: hitobito RAILS_DB_NAME: hitobito_test RAILS_TEST_DB_NAME: hitobito_test services: mysql: image: 'mysql:5.7' env: MYSQL_USER: 'hitobito' MYSQL_PASSWORD: 'hitobito' MYSQL_DATABASE: 'hitobito_test' MYSQL_ROOT_PASSWORD: 'root' ports: - '33066:3306' options: >- --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 10s --health-retries 10 memcached: image: 'memcached' ports: [ '11211:11211' ] steps: - name: 'create default (hitobito) dir' run: | mkdir hitobito working-directory: . - name: 'Setup OS' run: | sudo apt-get -qq update sudo apt-get install sphinxsearch echo "ruby version: $(ruby -v)" echo "node version: $(node -v)" echo "yarn version: $(yarn -v)" - name: 'Extract branch name' run: | echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV - name: 'Choose branch for dependencies' run: | echo "BRANCH_NAME: $BRANCH_NAME" HITOBITO_BRANCH=$([[ $BRANCH_NAME = 'stable' ]] && echo 'stable' || echo 'master') echo "HITOBITO_BRANCH=$HITOBITO_BRANCH" >> $GITHUB_ENV - name: 'Checkout hitobito' uses: actions/checkout@v2 with: repository: 'hitobito/hitobito' ref: '${{ env.HITOBITO_BRANCH }}' path: 'hitobito' - name: 'Copy Wagonfile.ci' run: | cp -v Wagonfile.ci Wagonfile - name: 'Set up Ruby' env: ImageOS: ubuntu20 uses: ruby/setup-ruby@v1.66.0 with: working-directory: hitobito - name: 'Checkout hitobito-lit' uses: actions/checkout@v2 with: path: 'hitobito_lit' - name: 'create cache key' run: cp Gemfile.lock Gemfile.lock.backup - uses: actions/cache@v2 with: path: hitobito/vendor/bundle key: ${{ runner.os }}-ruby-bundle-${{ hashFiles('**/Gemfile.lock.backup') }} restore-keys: | ${{ runner.os }}-ruby-bundle- - uses: actions/cache@v2 with: path: hitobito_lit/vendor/bundle key: ${{ runner.os }}-ruby-bundle-${{ hashFiles('**/Gemfile.lock.backup') }} restore-keys: | ${{ runner.os }}-ruby-bundle- - name: 'Bundle install core' run: | bundle install --jobs 4 --retry 3 --path vendor/bundle - name: 'Make changes to Gemfile.lock transparent' run: | git diff Gemfile.lock || true - name: 'Bundle install wagons' run: | hitobito_dir=$(realpath ./) for d in $hitobito_dir/../hitobito_*; do cd $d cp -v $hitobito_dir/Gemfile.lock ./ bundle install --jobs 4 --retry 3 --path vendor/bundle done - uses: actions/cache@v2 with: path: node_modules key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-node_modules- - name: 'Yarn install' run: | yarn install --frozen-lockfile - name: 'Run Webpacker' run: | RAILS_ENV=test bundle exec rake webpacker:compile - name: 'Run Wagon Lint and Tests' run: | bundle exec rake db:create ci:wagon --trace