name: "upstream"

concurrency:
  group: "${{github.workflow}}-${{github.ref}}"
  cancel-in-progress: true

on:
  workflow_dispatch:
  schedule:
    - cron: "0 8 * * 5" # At 08:00 on Friday # https://crontab.guru/#0_8_*_*_5
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize]
    branches:
      - main
    paths:
      - .github/workflows/upstream.yml # this file

jobs:
  test:
    strategy:
      fail-fast: false
      matrix:
        ruby-version: ["head", "jruby-head", "truffleruby-head"]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{matrix.ruby-version}}
          bundler-cache: true
      - run: bundle exec rake test

  upstream:
    name: "upstream (${{matrix.name}})"
    strategy:
      fail-fast: false
      matrix:
        include:
          - { name: "nokogiri", git: "https://github.com/sparklemotion/nokogiri" }
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: ruby/setup-ruby@v1
        with: { ruby-version: "3.3" }
      - run: |
          bundle add ${{matrix.name}} --git="${{matrix.git}}"
          bundle show
      - run: bundle exec rake test
