<commit_before>name: ConformanceEKS (ci-eks)

# Any change in triggers needs to be reflected in the concurrency group.
on:
  issue_comment:
    types:
      - created
  # Run every 6 hours
  schedule:
    - cron:  '0 1/6 * * *'
  ### FOR TESTING PURPOSES
  # pull_request:
  #  types:
  #    - "labeled"
  ###

concurrency:
  # In case of PR comment, we can't simply append the comment to the group name
  # as that is too long and results in an error. Instead we check if it's a
  # trigger phrase and append a simple 'trigger-phrase'.
  group: |
    "${{ github.workflow }} ${{ github.event.issue.pull_request.url || 'scheduled' }}
     ${{ (startsWith(github.event.comment.body, 'ci-eks') ||
          startsWith(github.event.comment.body, 'test-me-please')) && 'trigger-phrase' }}"
  cancel-in-progress: true

env:
  clusterName: ${{ github.repository_owner }}-${{ github.event.repository.name }}-${{ github.run_id }}
  region: us-east-2
  check_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

jobs:
  check_changes:
    name: Deduce required tests from code changes
    if: |
      (github.event.issue.pull_request && (
        startsWith(github.event.comment.body, 'ci-eks') ||
        (startsWith(github.event.comment.body, 'test-me-please'))
      )) ||
      (github.event_name == 'schedule' && github.repository == 'cilium/cilium') ||
      github.event.label.name == 'ci-run/eks'
    runs-on: ubuntu-latest
    outputs:
      tested: ${{ steps.tested-tree.outputs.src }}
    steps:
      - name: Retrieve pull request's base and head
        if: ${{ github.event.issue.pull_request }}
        id: pr
        run: |
          curl ${{ github.event.issue.pull_request.url }} > pr.json
          echo "::set-output name=base::$(jq -r '.base.sha' pr.json)"
          echo "::set-output name=head::$(jq -r '.head.sha' pr.json)"
      # Because we run on issue comments, we need to checkout the code for
      # paths-filter to work.
      - name: Checkout code
        if: ${{ github.event.issue.pull_request }}
        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
        with:
          persist-credentials: false
      - name: Check code changes
        if: ${{ github.event.issue.pull_request }}
        uses: dorny/paths-filter@78ab00f87740f82aec8ed8826eb4c3c851044126
        id: tested-tree
        with:
          base: ${{ steps.pr.outputs.base }}
          ref: ${{ steps.pr.outputs.head }}
          filters: |
            src:
              - '!(test|Documentation)/**'

  # When the test-me-please trigger is used, this job is skipped if the only
  # modified files were under test/ or Documentation/.
  installation-and-connectivity:
    needs: check_changes
    if: |
      (github.event.issue.pull_request && (
        startsWith(github.event.comment.body, 'ci-eks') ||
        (startsWith(github.event.comment.body, 'test-me-please') && (needs.check_changes.outputs.tested == 'true'))
      )) ||
      (github.event_name == 'schedule' && github.repository == 'cilium/cilium') ||
      github.event.label.name == 'ci-run/eks'
    runs-on: ubuntu-latest
    timeout-minutes: 45
    steps:
      - name: Set up job variables
        id: vars
        run: |
          if [ ${{ github.event.issue.pull_request || github.event.pull_request }} ]; then
            PR_API_JSON=$(curl \
              -H "Accept: application/vnd.github.v3+json" \
              -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
              ${{ github.event.issue.pull_request.url || github.event.pull_request.url }})
            SHA=$(echo "$PR_API_JSON" | jq -r ".head.sha")
            OWNER=$(echo "$PR_API_JSON" | jq -r ".number")
          else
            SHA=${{ github.sha }}
            OWNER=${{ github.sha }}
          fi

          CILIUM_INSTALL_DEFAULTS="--cluster-name=${{ env.clusterName }} \
            --agent-image=quay.io/${{ github.repository_owner }}/cilium-ci \
            --operator-image=quay.io/${{ github.repository_owner }}/operator-aws-ci \
            --version=${SHA} \
            --wait=false \
            --config monitor-aggregation=none"
          HUBBLE_ENABLE_DEFAULTS="--relay-image=quay.io/${{ github.repository_owner }}/hubble-relay-ci \
            --relay-version=${SHA}"
          echo ::set-output name=cilium_install_defaults::${CILIUM_INSTALL_DEFAULTS}
          echo ::set-output name=hubble_enable_defaults::${HUBBLE_ENABLE_DEFAULTS}
          echo ::set-output name=sha::${SHA}
          echo ::set-output name=owner::${OWNER}

      - name: Set commit status to pending
        uses: Sibz/github-status-action@67af1f4042a5a790681aad83c44008ca6cfab83d
        with:
          authToken: ${{ secrets.GITHUB_TOKEN }}
          sha: ${{ steps.vars.outputs.sha }}
          context: ${{ github.workflow }}
          description: Connectivity test in progress...
          state: pending
          target_url: ${{ env.check_url }}

      - name: Install Cilium CLI
        run: |
          curl -LO https://github.com/cilium/cilium-cli/releases/download/v0.6/cilium-linux-amd64.tar.gz
          sudo tar xzvfC cilium-linux-amd64.tar.gz /usr/bin
          rm cilium-linux-amd64.tar.gz

      - name: Install eksctl CLI
        run: |
          curl -LO "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz"
          sudo tar xzvfC eksctl_$(uname -s)_amd64.tar.gz /usr/bin
          rm eksctl_$(uname -s)_amd64.tar.gz

      - name: Set up AWS CLI credentials
        uses: aws-actions/configure-aws-credentials@0309c38ebd10f90dfbb3889431bcf4ea38088012
        with:
          aws-access-key-id: ${{ secrets.AWS_PR_SA_ID }}
          aws-secret-access-key: ${{ secrets.AWS_PR_SA_KEY }}
          aws-region: ${{ env.region }}

      - name: Create EKS cluster without nodegroup
        run: |
          eksctl create cluster \
            --name ${{ env.clusterName }} \
            --tags "usage=${{ github.repository_owner }}-${{ github.event.repository.name }},owner=${{ steps.vars.outputs.owner }}" \
            --without-nodegroup

      - name: Wait for images to be available
        timeout-minutes: 10
        shell: bash
        run: |<commit_msg>build(deps): bump aws-actions/configure-aws-credentials<commit_after>name: ConformanceEKS (ci-eks)

# Any change in triggers needs to be reflected in the concurrency group.
on:
  issue_comment:
    types:
      - created
  # Run every 6 hours
  schedule:
    - cron:  '0 1/6 * * *'
  ### FOR TESTING PURPOSES
  # pull_request:
  #  types:
  #    - "labeled"
  ###

concurrency:
  # In case of PR comment, we can't simply append the comment to the group name
  # as that is too long and results in an error. Instead we check if it's a
  # trigger phrase and append a simple 'trigger-phrase'.
  group: |
    "${{ github.workflow }} ${{ github.event.issue.pull_request.url || 'scheduled' }}
     ${{ (startsWith(github.event.comment.body, 'ci-eks') ||
          startsWith(github.event.comment.body, 'test-me-please')) && 'trigger-phrase' }}"
  cancel-in-progress: true

env:
  clusterName: ${{ github.repository_owner }}-${{ github.event.repository.name }}-${{ github.run_id }}
  region: us-east-2
  check_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

jobs:
  check_changes:
    name: Deduce required tests from code changes
    if: |
      (github.event.issue.pull_request && (
        startsWith(github.event.comment.body, 'ci-eks') ||
        (startsWith(github.event.comment.body, 'test-me-please'))
      )) ||
      (github.event_name == 'schedule' && github.repository == 'cilium/cilium') ||
      github.event.label.name == 'ci-run/eks'
    runs-on: ubuntu-latest
    outputs:
      tested: ${{ steps.tested-tree.outputs.src }}
    steps:
      - name: Retrieve pull request's base and head
        if: ${{ github.event.issue.pull_request }}
        id: pr
        run: |
          curl ${{ github.event.issue.pull_request.url }} > pr.json
          echo "::set-output name=base::$(jq -r '.base.sha' pr.json)"
          echo "::set-output name=head::$(jq -r '.head.sha' pr.json)"
      # Because we run on issue comments, we need to checkout the code for
      # paths-filter to work.
      - name: Checkout code
        if: ${{ github.event.issue.pull_request }}
        uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
        with:
          persist-credentials: false
      - name: Check code changes
        if: ${{ github.event.issue.pull_request }}
        uses: dorny/paths-filter@78ab00f87740f82aec8ed8826eb4c3c851044126
        id: tested-tree
        with:
          base: ${{ steps.pr.outputs.base }}
          ref: ${{ steps.pr.outputs.head }}
          filters: |
            src:
              - '!(test|Documentation)/**'

  # When the test-me-please trigger is used, this job is skipped if the only
  # modified files were under test/ or Documentation/.
  installation-and-connectivity:
    needs: check_changes
    if: |
      (github.event.issue.pull_request && (
        startsWith(github.event.comment.body, 'ci-eks') ||
        (startsWith(github.event.comment.body, 'test-me-please') && (needs.check_changes.outputs.tested == 'true'))
      )) ||
      (github.event_name == 'schedule' && github.repository == 'cilium/cilium') ||
      github.event.label.name == 'ci-run/eks'
    runs-on: ubuntu-latest
    timeout-minutes: 45
    steps:
      - name: Set up job variables
        id: vars
        run: |
          if [ ${{ github.event.issue.pull_request || github.event.pull_request }} ]; then
            PR_API_JSON=$(curl \
              -H "Accept: application/vnd.github.v3+json" \
              -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
              ${{ github.event.issue.pull_request.url || github.event.pull_request.url }})
            SHA=$(echo "$PR_API_JSON" | jq -r ".head.sha")
            OWNER=$(echo "$PR_API_JSON" | jq -r ".number")
          else
            SHA=${{ github.sha }}
            OWNER=${{ github.sha }}
          fi

          CILIUM_INSTALL_DEFAULTS="--cluster-name=${{ env.clusterName }} \
            --agent-image=quay.io/${{ github.repository_owner }}/cilium-ci \
            --operator-image=quay.io/${{ github.repository_owner }}/operator-aws-ci \
            --version=${SHA} \
            --wait=false \
            --config monitor-aggregation=none"
          HUBBLE_ENABLE_DEFAULTS="--relay-image=quay.io/${{ github.repository_owner }}/hubble-relay-ci \
            --relay-version=${SHA}"
          echo ::set-output name=cilium_install_defaults::${CILIUM_INSTALL_DEFAULTS}
          echo ::set-output name=hubble_enable_defaults::${HUBBLE_ENABLE_DEFAULTS}
          echo ::set-output name=sha::${SHA}
          echo ::set-output name=owner::${OWNER}

      - name: Set commit status to pending
        uses: Sibz/github-status-action@67af1f4042a5a790681aad83c44008ca6cfab83d
        with:
          authToken: ${{ secrets.GITHUB_TOKEN }}
          sha: ${{ steps.vars.outputs.sha }}
          context: ${{ github.workflow }}
          description: Connectivity test in progress...
          state: pending
          target_url: ${{ env.check_url }}

      - name: Install Cilium CLI
        run: |
          curl -LO https://github.com/cilium/cilium-cli/releases/download/v0.6/cilium-linux-amd64.tar.gz
          sudo tar xzvfC cilium-linux-amd64.tar.gz /usr/bin
          rm cilium-linux-amd64.tar.gz

      - name: Install eksctl CLI
        run: |
          curl -LO "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz"
          sudo tar xzvfC eksctl_$(uname -s)_amd64.tar.gz /usr/bin
          rm eksctl_$(uname -s)_amd64.tar.gz

      - name: Set up AWS CLI credentials
        uses: aws-actions/configure-aws-credentials@13d241b293754004c80624b5567555c4a39ffbe3
        with:
          aws-access-key-id: ${{ secrets.AWS_PR_SA_ID }}
          aws-secret-access-key: ${{ secrets.AWS_PR_SA_KEY }}
          aws-region: ${{ env.region }}

      - name: Create EKS cluster without nodegroup
        run: |
          eksctl create cluster \
            --name ${{ env.clusterName }} \
            --tags "usage=${{ github.repository_owner }}-${{ github.event.repository.name }},owner=${{ steps.vars.outputs.owner }}" \
            --without-nodegroup

      - name: Wait for images to be available
        timeout-minutes: 10
        shell: bash
        run: |
{'fraction_non_alphanumeric': 0.14197431781701444, 'fraction_numerical': 0.020064205457463884, 'mean_word_length': 2.302676914921813, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6255463', 'n_tokens_mistral': 4237, 'n_tokens_neox': 3951, 'n_words': 810}