name: Continuous Integration

on:
  push:
    branches:
    - master
  pull_request:
    branches:
    - master

jobs:
  j4:
    if: "!contains(github.event.commits[0].message, '[ci skip]')"
    name: "Jekyll ${{ matrix.jekyll_version }} (Ruby ${{ matrix.ruby_version }})"
    runs-on: 'ubuntu-latest'
    env:
      JEKYLL_VERSION: ${{ matrix.jekyll_version }}
    strategy:
      fail-fast: false
      matrix:
        ruby_version:
        - 2.5
        - 2.7
        - 3.0
        jekyll_version:
        - "~> 4.0"
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 5
      - name: "Set up Ruby ${{ matrix.ruby_version }}"
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby_version }}
          bundler-cache: true
      - name: Execute tests
        run:  bundle exec rspec
  j3:
    if: "!contains(github.event.commits[0].message, '[ci skip]')"
    name: "Jekyll ${{ matrix.jekyll_version }} (Ruby ${{ matrix.ruby_version }})"
    runs-on: 'ubuntu-latest'
    env:
      JEKYLL_VERSION: ${{ matrix.jekyll_version }}
    strategy:
      fail-fast: false
      matrix:
        ruby_version:
        - 2.5
        jekyll_version:
        - "~> 3.9"
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 5
      - name: "Set up Ruby ${{ matrix.ruby_version }}"
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby_version }}
          bundler-cache: true
      - name: Execute tests
        run:  bundle exec rspec

  style_check:
    if: "!contains(github.event.commits[0].message, '[ci skip]')"
    name: "Code Style Check (Ruby ${{ matrix.ruby_version }})"
    runs-on: 'ubuntu-latest'
    strategy:
      fail-fast: false
      matrix:
        ruby_version:
        - 2.5
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 5
      - name: "Set up Ruby ${{ matrix.ruby_version }}"
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby_version }}
          bundler-cache: true
      - name: Check Style Offenses
        run:  bundle exec rubocop -S -D

  gem_build:
    if: "!contains(github.event.commits[0].message, '[ci skip]')"
    name: "Test Gem build (Ruby ${{ matrix.ruby_version }})"
    runs-on: 'ubuntu-latest'
    strategy:
      fail-fast: false
      matrix:
        ruby_version:
        - 2.5
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 5
      - name: "Set up Ruby ${{ matrix.ruby_version }}"
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby_version }}
          bundler-cache: true
      - name: Test Gem build
        run:  bundle exec gem build jekyll-seo-tag.gemspec
