<commit_before>name: Continuous integration
on: [push, pull_request]

jobs:
  # This matrix job runs the test suite against multiple Ruby and Rails versions
  test_matrix:
    strategy:
      fail-fast: false
      matrix:
        # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
        ruby: [2.7, '3.0', 3.1]
        # Test against multiple Rails versions
        gemfile: [rails_6, rails_7]
    runs-on: ubuntu-latest
    env:
      BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
    steps:
    - uses: actions/checkout@v3
    - uses: ruby/setup-ruby@v1
      with:
        ruby-version: ${{ matrix.ruby }}
        bundler-cache: true
    - uses: actions/setup-node@v3.0.0
      with:
        node-version: lts/* # use the latest LTS release
        cache: yarn
    - run: yarn install
    - run: bundle exec rake

  # This job is needed to work around the fact that matrix jobs spawn multiple status checks – i.e. one job per variant.
  # The branch protection rules depend on this as a composite job to ensure that all preceding test_matrix checks passed.
  # Solution taken from: https://github.community/t/status-check-for-a-matrix-jobs/127354/3
  test:
    needs: test_matrix
    runs-on: ubuntu-latest
    steps:
      - run: echo "All matrix tests have passed 🚀"

  release:
    needs: test
    runs-on: ubuntu-latest
    if: ${{ github.ref == 'refs/heads/main' }}
    permissions:
      contents: write
    steps:
    - uses: actions/checkout@v3
    - uses: ruby/setup-ruby@v1
      with:
        rubygems: latest
    - uses: actions/setup-node@v3.0.0
      with:
        node-version: lts/* # use the latest LTS release
    - run: yarn install
    - env:
        GEM_HOST_API_KEY: ${{ secrets.ALPHAGOV_RUBYGEMS_API_KEY }}
      run: |
        VERSION=$(ruby -e "puts eval(File.read('govuk_admin_template.gemspec')).version")
        GEM_VERSION=$(gem list --exact --remote govuk_admin_template)

        if [ "${GEM_VERSION}" != "govuk_admin_template (${VERSION})" ]; then
          gem build govuk_admin_template.gemspec
          gem push "govuk_admin_template-${VERSION}.gem"
        fi

        if ! git ls-remote --tags --exit-code origin v${VERSION}; then
          git tag v${VERSION}<commit_msg>Bump actions/setup-node from 3.0.0 to 3.1.1<commit_after>name: Continuous integration
on: [push, pull_request]

jobs:
  # This matrix job runs the test suite against multiple Ruby and Rails versions
  test_matrix:
    strategy:
      fail-fast: false
      matrix:
        # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
        ruby: [2.7, '3.0', 3.1]
        # Test against multiple Rails versions
        gemfile: [rails_6, rails_7]
    runs-on: ubuntu-latest
    env:
      BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
    steps:
    - uses: actions/checkout@v3
    - uses: ruby/setup-ruby@v1
      with:
        ruby-version: ${{ matrix.ruby }}
        bundler-cache: true
    - uses: actions/setup-node@v3.1.1
      with:
        node-version: lts/* # use the latest LTS release
        cache: yarn
    - run: yarn install
    - run: bundle exec rake

  # This job is needed to work around the fact that matrix jobs spawn multiple status checks – i.e. one job per variant.
  # The branch protection rules depend on this as a composite job to ensure that all preceding test_matrix checks passed.
  # Solution taken from: https://github.community/t/status-check-for-a-matrix-jobs/127354/3
  test:
    needs: test_matrix
    runs-on: ubuntu-latest
    steps:
      - run: echo "All matrix tests have passed 🚀"

  release:
    needs: test
    runs-on: ubuntu-latest
    if: ${{ github.ref == 'refs/heads/main' }}
    permissions:
      contents: write
    steps:
    - uses: actions/checkout@v3
    - uses: ruby/setup-ruby@v1
      with:
        rubygems: latest
    - uses: actions/setup-node@v3.1.1
      with:
        node-version: lts/* # use the latest LTS release
    - run: yarn install
    - env:
        GEM_HOST_API_KEY: ${{ secrets.ALPHAGOV_RUBYGEMS_API_KEY }}
      run: |
        VERSION=$(ruby -e "puts eval(File.read('govuk_admin_template.gemspec')).version")
        GEM_VERSION=$(gem list --exact --remote govuk_admin_template)

        if [ "${GEM_VERSION}" != "govuk_admin_template (${VERSION})" ]; then
          gem build govuk_admin_template.gemspec
          gem push "govuk_admin_template-${VERSION}.gem"
        fi

        if ! git ls-remote --tags --exit-code origin v${VERSION}; then
          git tag v${VERSION}
{'fraction_non_alphanumeric': 0.11067193675889328, 'fraction_numerical': 0.014492753623188406, 'mean_word_length': 2.44553706505295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2848529', 'n_tokens_mistral': 1523, 'n_tokens_neox': 1445, 'n_words': 424}