<commit_before>name: Build Native

on:
  workflow_dispatch:
  pull_request:
    types: [ opened ]
  issue_comment:
    types: [ created ]

jobs:
  check:
    name: Check conditions
    runs-on: ubuntu-latest
    outputs:
      ref: ${{ steps.output.outputs.ref }}
    steps:
      - name: Check if PR comment trigger is present
        if: github.event_name != 'workflow_dispatch'
        uses: khan/pull-request-comment-trigger@v1.1.0
        id: check
        with:
          trigger: '/native'
          reaction: rocket
          prefix_only: true
        env:
          GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
      - name: Get PR branch
        uses: xt0rted/pull-request-comment-branch@v1
        if: steps.check.outputs.triggered == 'true'
        id: comment-branch
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
      # This will set the branch to use:
      # - if workflow_dispatch, use the branch that was chosen when running the workflow
      # - if it is a comment on a PR, and the trigger matches, use the PR branch
      - name: Set job output
        id: output
        run: |
          echo "::echo::on"
          if [[ "${{ github.event_name == 'workflow_dispatch' }}" == 'true' ]]
          then
            echo "::set-output name=ref::${{ github.ref_name }}"
          elif [[ "${{ steps.check.outputs.triggered }}" == 'true' ]]
          then
            echo "::set-output name=ref::${{ steps.comment-branch.outputs.head_ref }}"
          else
            echo ""
          fi

  matrix:
    name: Build matrix
    runs-on: ubuntu-latest
    needs: [check]
    if: needs.check.outputs.ref
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ needs.check.outputs.ref }}
      - name: Build matrix from Makefile
        id: set-matrix
        # parse the Makefile to retrieve the list of targets in 'native-all', without 'native'
        run: |
          matrix=$((
            echo '{ "target" : ['
            sed -n "/^native-all *: */ { s///; p }" Makefile | sed "s/^native\s//g" | sed 's/ /, /g' | xargs -n 1 echo | sed -r 's/^([^,]*)(,?)$/"\1"\2/'
            echo " ]}"
          ) | jq -c .)
          echo $matrix | jq .
          echo "::set-output name=matrix::$matrix"

  build:
    name: Build native libraries
    runs-on: ubuntu-latest
    needs: [check, matrix]
    strategy:
      matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ needs.check.outputs.ref }}
      # Delete existing libs so we only upload the generated one into the artifact
      - name: Delete existing native libs
        run: rm -fr src/main/resources/org/sqlite/native
      - name: Build native libraries
        run: make ${{ matrix.target }}
        env:
          OCI_EXE: docker
      - name: Upload native libraries
        uses: actions/upload-artifact@v3
        with:
          name: native-libs
          path: src/main/resources/org/sqlite/native/

  push:
    name: Push new native libraries to branch
    runs-on: ubuntu-latest
    needs: [check, build]<commit_msg>ci: replace deprecated set-output usage<commit_after>name: Build Native

on:
  workflow_dispatch:
  pull_request:
    types: [ opened ]
  issue_comment:
    types: [ created ]

jobs:
  check:
    name: Check conditions
    runs-on: ubuntu-latest
    outputs:
      ref: ${{ steps.output.outputs.ref }}
    steps:
      - name: Check if PR comment trigger is present
        if: github.event_name != 'workflow_dispatch'
        uses: khan/pull-request-comment-trigger@v1.1.0
        id: check
        with:
          trigger: '/native'
          reaction: rocket
          prefix_only: true
        env:
          GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
      - name: Get PR branch
        uses: xt0rted/pull-request-comment-branch@v1
        if: steps.check.outputs.triggered == 'true'
        id: comment-branch
        with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
      # This will set the branch to use:
      # - if workflow_dispatch, use the branch that was chosen when running the workflow
      # - if it is a comment on a PR, and the trigger matches, use the PR branch
      - name: Set job output
        id: output
        run: |
          echo "::echo::on"
          if [[ "${{ github.event_name == 'workflow_dispatch' }}" == 'true' ]]
          then
            echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT
          elif [[ "${{ steps.check.outputs.triggered }}" == 'true' ]]
          then
            echo "ref=${{ steps.comment-branch.outputs.head_ref }}" >> $GITHUB_OUTPUT
          else
            echo ""
          fi

  matrix:
    name: Build matrix
    runs-on: ubuntu-latest
    needs: [check]
    if: needs.check.outputs.ref
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ needs.check.outputs.ref }}
      - name: Build matrix from Makefile
        id: set-matrix
        # parse the Makefile to retrieve the list of targets in 'native-all', without 'native'
        run: |
          matrix=$((
            echo '{ "target" : ['
            sed -n "/^native-all *: */ { s///; p }" Makefile | sed "s/^native\s//g" | sed 's/ /, /g' | xargs -n 1 echo | sed -r 's/^([^,]*)(,?)$/"\1"\2/'
            echo " ]}"
          ) | jq -c .)
          echo $matrix | jq .
          echo "matrix=$matrix" >> $GITHUB_OUTPUT

  build:
    name: Build native libraries
    runs-on: ubuntu-latest
    needs: [check, matrix]
    strategy:
      matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ needs.check.outputs.ref }}
      # Delete existing libs so we only upload the generated one into the artifact
      - name: Delete existing native libs
        run: rm -fr src/main/resources/org/sqlite/native
      - name: Build native libraries
        run: make ${{ matrix.target }}
        env:
          OCI_EXE: docker
      - name: Upload native libraries
        uses: actions/upload-artifact@v3
        with:
          name: native-libs
          path: src/main/resources/org/sqlite/native/

  push:
    name: Push new native libraries to branch
    runs-on: ubuntu-latest
    needs: [check, build]
{'fraction_non_alphanumeric': 0.125920125293657, 'fraction_numerical': 0.0034455755677368833, 'mean_word_length': 1.9027272727272728, 'pattern_counts': {'":': 5, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '7537635', 'n_tokens_mistral': 1985, 'n_tokens_neox': 1930, 'n_words': 543}