name: Third-Party Repository Profiling

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
jobs:
  build_n_profile:
    name: "Third-Party Repo Profile (Jekyll ${{ matrix.jekyll_version }}, Ruby ${{ matrix.ruby_version }})"
    runs-on: "ubuntu-latest"
    strategy:
      fail-fast: false
      matrix:
        ruby_version:
          - 2.7
        jekyll_version:
          - "~> 4.0"
          - "~> 3.9"
    env:
      BUNDLE_GEMFILE: "sandbox/Gemfile"
      BUNDLE_PATH: "vendor/bundle"
      BUNDLE_JOBS: 4
      BUNDLE_RETRY: 3
      JEKYLL_VERSION: ${{ matrix.jekyll_version }}
    steps:
    - name: Checkout Jekyll SEO Tag
      uses: actions/checkout@v2
      with:
        fetch-depth: 5
        path: jekyll-seo-tag
    - name: Checkout Third-Party Repository (WITHOUT SEO Tag)
      uses: actions/checkout@v2
      with:
        repository: ashmaroli/tomjoht.github.io
        ref: "no-seo-tag"
        path: alpha-sandbox
    - name: Checkout Same Third-Party Repository (WITH SEO Tag)
      uses: actions/checkout@v2
      with:
        repository: ashmaroli/tomjoht.github.io
        ref: "seo-tag"
        path: sandbox
    - name: "Set up Ruby ${{ matrix.ruby_version }}"
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: ${{ matrix.ruby_version }}
        bundler-cache: true
    - name: Run Jekyll Build (WITHOUT SEO Tag) 3 times
      run: |
        bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace
        bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace
        bundle exec jekyll build -s alpha-sandbox -d alpha-sandbox/_site --trace
    - name: Run Jekyll Build (WITH SEO Tag) 3 times
      run: |
        bundle exec jekyll build -s sandbox -d sandbox/_site --trace
        bundle exec jekyll build -s sandbox -d sandbox/_site --trace
        bundle exec jekyll build -s sandbox -d sandbox/_site --trace
    - name: Memory Analysis of Jekyll Build (WITH SEO Tag)
      run: bash jekyll-seo-tag/.github/workflows/scripts/memprof
