Release Robusta

name: Release Robusta

on:
  release:
    types: [published]

env:
  PROJECT_ID: ${{ secrets.GKE_PROD_PROJECT }}
# ` ``  GKE_ZONE: us-central1-c   # TODO: update to cluster zone
  RELEASE_VER : ${{ github.event.release.tag_name }}
jobs:

  setup-build-publish-deploy:
    name: Build images
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: Get release version
      run: echo "$RELEASE_VER"

    - uses: google-github-actions/setup-gcloud@v0.2.0
      with:
        service_account_key: ${{ secrets.GKE_PROD_SA_KEY }}
        project_id: ${{ secrets.GKE_PROD_PROJECT }}
        export_default_credentials: true

    # Configure Docker to use the gcloud command-line tool as a credential helper for authentication
    - run: |-
        gcloud auth configure-docker us-central1-docker.pkg.dev

    - run: |-
        gcloud config get-value project

    - run: |-
        curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
        chmod a+x skaffold

    - name: Update package version
      run: |
        sed -i 's/0.0.0/${{env.RELEASE_VER}}/g' src/robusta/_version.py pyproject.toml helm/robusta/Chart.yaml helm/robusta/values.yaml
        sed -i 's/0.0.1/${{env.RELEASE_VER}}/g' helm/robusta/Chart.yaml

    # Set up the buildx to run build for multiple platforms
    - name: Set up QEMU
      uses: docker/setup-qemu-action@c5ffa2a61740d9877bd1f40899a87c8ec93b0d9f

    - name: Docker Setup Buildx
      uses: docker/setup-buildx-action@bea6a01aa40b4d58b0382d47e1c4a70137af67b1
      with:
        config-inline: |
          [worker.oci]
            enabled = true
            platforms = [ "linux/amd64", "linux/arm64" ]

    # see https://github.com/GoogleContainerTools/skaffold/issues/4842
    - name: Cache skaffold image builds & config
      uses: actions/cache@v2
      with:
        path: ~/.skaffold/
        key: fixed-${{ github.sha }}
        restore-keys: |
          fixed-${{ github.sha }}
          fixed-

    - name: Login to Docker Hub
      uses: docker/login-action@v1
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}

    - name: Build with skaffold
      run: ./skaffold build --profile release --file-output=container-ids.json --tag='${{env.RELEASE_VER}}'

    - name: Save artifact with tags of built containers
      uses: actions/upload-artifact@v2
      with:
        name: container-ids
        path: container-ids.json

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: 3.9

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install twine

    - name: Prepare pypi dist
      run: |
        curl -sSL https://install.python-poetry.org | python3 - --version 1.4.0
        poetry config virtualenvs.create false
        poetry install --extras "all"
        poetry publish --build -u __token__ -p ${{ secrets.PYPI_PROJECT_TOKEN }}

    - name: Save artifact with helm chart
      uses: actions/upload-artifact@v2
      with:
        name: helm-chart
        path: helm/robusta/

    - name: Upload helm chart
      run: |
        cd helm && ./upload_chart.sh

    - name: Release Docker to Dockerhub
      run: |-
        docker buildx build \
        --build-arg BUILDKIT_INLINE_CACHE=1 \
        --platform linux/arm64,linux/amd64 \
        --cache-from us-central1-docker.pkg.dev/genuine-flight-317411/devel/robusta:cache \
        --tag robustadev/robusta-runner:${{env.RELEASE_VER}} \
        --push \
        .


Test Poetry lock file

name: Test Poetry lock file
on:
  - push
  - pull_request
jobs:
  run_tests:
    name: Test lock file
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.9
      - name: Run poetry lock
        run: |
          curl -sSL https://install.python-poetry.org | python3 -
          poetry lock --check


Automated message for issues

name: Automated message for issues
on:
  issues:
    types:
      - opened
jobs:
  build:
    name: Welcome new contributor 🎉
    permissions:
      issues: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/first-interaction@v1
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          issue-message: "Hi 👋, thanks for opening an issue! Please note, it may take some time for us to respond, but we'll get back to you as soon as we can! \n\n- 💬 **Slack Community:** Join Robusta team and other contributors on Slack [here](https://bit.ly/robusta-slack).\n- 📖 **Docs:** Find our documentation [here](https://docs.robusta.dev/master/).\n- 🎥 **YouTube Channel:** Watch our videos [here](https://www.youtube.com/@RobustaDev)."


name: Apply 'untriaged' label during issue lifecycle

on:
  issues:
    types: [opened, reopened, transferred]

jobs:
  apply-label:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@v6
        with:
          script: |
            github.rest.issues.addLabels({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              labels: ['untriaged']
            })


Backport

name: Backport
on:
  pull_request_target:
    types:
      - closed
      - labeled

jobs:
  backport:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    name: Backport
    steps:
      - name: GitHub App token
        id: github_app_token
        uses: tibdex/github-app-token@v1.5.0
        with:
          app_id: ${{ secrets.APP_ID }}
          private_key: ${{ secrets.APP_PRIVATE_KEY }}
          installation_id: 22958780

      - name: Backport
        uses: VachaShah/backport@v1.1.4
        with:
          github_token: ${{ steps.github_app_token.outputs.token }}
          branch_name: backport/backport-${{ github.event.number }}


Changelog Verifier

name: "Changelog Verifier"
on:
  pull_request:
    types: [opened, edited, review_requested, synchronize, reopened, ready_for_review, labeled, unlabeled]

jobs:
  # Enforces the update of a changelog file on every pull request
  verify-changelog:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          ref: ${{ github.event.pull_request.head.sha }}

      - uses: dangoslen/changelog-enforcer@v3
        with:
          skipLabels: "autocut, skip-changelog"


CI

---
name: CI

on: [push, pull_request]

jobs:
  package:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3
      - name: Set up Python 3.8
        uses: actions/setup-python@v4
        with:
          python-version: 3.8
      - name: Install dependencies
        run: |
          python3.8 -m pip install setuptools wheel twine
      - name: Build packages
        run: |
          python3.8 utils/build-dists.py
      - name: Check packages
        run: |
          set -exo pipefail;
          if [ $(python3.8 -m twine check dist/* | grep -c 'warning') != 0 ]; then exit 1; fi

  lint:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3
      - name: Set up Python 3.8
        uses: actions/setup-python@v4
        with:
          python-version: 3.8
      - name: Install dependencies
        run: |
          python3.8 -m pip install nox
      - name: Lint the code
        run: nox --no-error-on-missing-interpreter -s lint

  test-build-distribution:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3
      - name: Set up Python 3.7
        uses: actions/setup-python@v4
        with:
          python-version: 3.7
      - name: Install build tools
        run: |
          python3.7 -m pip install --upgrade build
      - name: Build project for distribution
        run: |
          python3.7 -m build

  test-linux:
    runs-on: ${{ matrix.runner }}

    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
        runner: ['ubuntu-latest']

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3
      - name: Setup Python - ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
        env:
          PIP_NO_PYTHON_VERSION_WARNING: 1
          PIP_DISABLE_PIP_VERSION_CHECK: 1
      - name: Set up Python 3.8 for Nox
        if: matrix.python-version != '3.8'
        uses: actions/setup-python@v4
        with:
          python-version: 3.8
      - name: Install nox
        run: |
          python3.8 -m pip install nox
      - name: Run Tests
        run: |
          nox --no-error-on-missing-interpreter -rs test


name: Delete merged branch of the backport PRs
on:
  pull_request:
    types:
      - closed

jobs:
  delete-branch:
    runs-on: ubuntu-latest
    if: startsWith(github.event.pull_request.head.ref,'backport/')
    steps:
      - name: Delete merged branch
        uses: SvanBoxel/delete-merged-branch@main
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


Dependabot PR actions

name: Dependabot PR actions
on: pull_request

jobs:
  dependabot:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
      contents: write
    if: ${{ github.actor == 'dependabot[bot]' }}
    steps:
      - name: GitHub App token
        id: github_app_token
        uses: tibdex/github-app-token@v1.5.0
        with:
          app_id: ${{ secrets.APP_ID }}
          private_key: ${{ secrets.APP_PRIVATE_KEY }}
          installation_id: 22958780

      - name: Check out code
        uses: actions/checkout@v2
        with:
          token: ${{ steps.github_app_token.outputs.token }}

      - name: Update the changelog
        uses: dangoslen/dependabot-changelog-helper@v1
        with:
          version: 'Unreleased'

      - name: Commit the changes
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: "Update changelog"
          branch: ${{ github.head_ref }}
          commit_user_name: dependabot[bot]
          commit_user_email: support@github.com
          commit_options: '--signoff'


Integration with Unreleased OpenSearch

name: Integration with Unreleased OpenSearch

on:
  push:
  pull_request:
    branches:
      - "main"

jobs:
  integ-test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        opensearch_ref: [ '1.x', '2.x', '2.0', 'main' ]
        python-version: [ '3.8' ]

    steps:
      - name: Checkout OpenSearch
        uses: actions/checkout@v3
        with:
          repository: opensearch-project/opensearch
          ref: ${{ matrix.opensearch_ref }}
          path: opensearch

      - name: Get OpenSearch branch top
        id: get-key
        working-directory: opensearch
        run: echo key=`git log -1 --format='%H'` >> $GITHUB_OUTPUT

      - name: Restore cached build
        id: cache-restore
        uses: actions/cache/restore@v3
        with:
          path: opensearch/distribution/archives/linux-tar/build/distributions
          key: ${{ steps.get-key.outputs.key }}

      - name: Assemble OpenSearch
        if: steps.cache-restore.outputs.cache-hit != 'true'
        working-directory: opensearch
        run: ./gradlew :distribution:archives:linux-tar:assemble

      - name: Save cached build
        if: steps.cache-restore.outputs.cache-hit != 'true'
        uses: actions/cache/save@v3
        with:
          path: opensearch/distribution/archives/linux-tar/build/distributions
          key: ${{ steps.get-key.outputs.key }}

      - name: Run OpenSearch
        working-directory: opensearch/distribution/archives/linux-tar/build/distributions
        run: |
          tar xf opensearch-min-*
          ./opensearch-*/bin/opensearch &
          for attempt in {1..20}; do sleep 5; if curl -s localhost:9200; then echo '=====> ready'; break; fi; echo '=====> waiting...'; done

      - name: Checkout High Level Python Client
        uses: actions/checkout@v3
        with:
          path: dsl-py

      - name: Setup Python - ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
        env:
          PIP_NO_PYTHON_VERSION_WARNING: 1

      - name: Install nox
        run: |
          python -m pip install nox

      - name: Run integration tests
        working-directory: dsl-py
        run: |
          nox --no-error-on-missing-interpreter -rs test

      - name: Save server logs
        if: failure()
        uses: actions/upload-artifact@v3
        with:
          name: opensearch-logs-${{ matrix.opensearch_ref }}-python-${{ matrix.python-version }}
          path: |
            opensearch/distribution/archives/linux-tar/build/distributions/**/logs/*


Integration tests

name: Integration tests

on: [push, pull_request]

jobs:
  integration:
    name: Integ
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        version: [ '1.0.1', '1.1.0', '1.2.4', '1.3.7', '2.0.1', '2.1.0', '2.2.1', '2.3.0', '2.4.0', '2.5.0' ]
        secured: [ "true", "false" ]
        python-version: [ '3.8' ]

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Clean docker containers
        run: |
          docker volume prune --force
          docker network prune --force
          docker system prune --volumes --force

      - name: Launch OpenSearch cluster
        run: |
          export OPENSEARCH_VERSION=${{ matrix.entry.version }}
          export SECURE_INTEGRATION=${{ matrix.secured }}
          docker-compose --project-directory .ci/opensearch build
          docker-compose --project-directory .ci/opensearch up -d

      - name: Setup Python - ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
        env:
          PIP_DISABLE_PIP_VERSION_CHECK: 1
          PIP_NO_PYTHON_VERSION_WARNING: 1

      - name: Install nox
        run: |
          python -m pip install --upgrade pip nox

      - name: Integ OpenSearch secured=${{ matrix.secured }}
        run: |
          export SECURE_INTEGRATION=${{ matrix.secured }}
          nox --no-error-on-missing-interpreter -rs test


Link Checker

name: Link Checker
on:
  push:
    branches:
      - "*"
  pull_request:
    branches:
      - "*"

jobs:
  linkchecker:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: lychee Link Checker
        id: lychee
        uses: lycheeverse/lychee-action@v1.0.8
        with:
          args: --accept=200,403,429  "**/*.html" "**/*.md" "**/*.txt" "**/*.json" --exclude "https://localhost:9200" --exclude-mail
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
      - name: Fail if there were link errors
        run: exit ${{ steps.lychee.outputs.exit_code }}


Release drafter

name: Release drafter

on:
  push:
    tags:
      - "*"

jobs:
  lint:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3
      - id: get_approvers
        run: |
          echo "approvers=$(cat .github/CODEOWNERS | grep @ | tr -d '* ' | sed 's/@/,/g' | sed 's/,//1')" >> $GITHUB_OUTPUT
      - uses: trstringer/manual-approval@v1
        with:
          secret: ${{ github.TOKEN }}
          approvers: ${{ steps.get_approvers.outputs.approvers }}
          minimum-approvals: 2
          issue-title: 'Release opensearch-dsl-py'
          issue-body: "Please approve or deny the release of opensearch-dsl-py. **Tag**: ${{ github.ref_name }}  **Commit**: ${{ github.sha }}"
          exclude-workflow-initiator-as-approver: true
      - name: Set up Python 3
        uses: actions/setup-python@v3
        with:
          python-version: '3.x'
      - name: Install build tools
        run: |
          python -m pip install --upgrade build
      - name: Build project for distribution
        run: |
          python -m build
          tar -zvcf artifacts.tar.gz dist
      - name: Draft a release
        uses: softprops/action-gh-release@v1
        with:
          draft: true
          generate_release_notes: true
          files: |
            artifacts.tar.gz


CodeQL

# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
  push:
    branches: [ "main" ]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ "main" ]
  schedule:
    - cron: '31 10 * * 2'

jobs:
  analyze:
    name: Analyze
    runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language: [ 'python' ]
        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
        # Use only 'java' to analyze code written in Java, Kotlin or both
        # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
        # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    # Initializes the CodeQL tools for scanning.
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v3
      with:
        languages: ${{ matrix.language }}
        # If you wish to specify custom queries, you can do so here or in a config file.
        # By default, queries listed here will override any specified in a config file.
        # Prefix the list here with "+" to use these queries and those in the config file.

        # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
        # queries: security-extended,security-and-quality

    # Autobuild attempts to build any compiled languages  (C/C++, C#, Go, or Java).
    # If this step fails, then you should remove it and run the build manually (see below)
    - name: Autobuild
      uses: github/codeql-action/autobuild@v3

    # ℹ Command-line programs to run using the OS shell.
    # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

    #   If the Autobuild fails above, remove it and uncomment the following three lines.
    #   modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

    # - run: |
    #     echo "Run, Build Application using script"
    #     ./location_of_script_within_repo/buildscript.sh

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v3
      with:
        category: "/language:${{matrix.language}}"


Main

name: Main

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

env:
  project-name: pymarkdown
  default-python-version: 3.8

jobs:

  lint:

    name: Project Quality Analysis
    runs-on: ubuntu-latest

    steps:

      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Setup Python ${{ env.default-python-version }}
        uses: actions/setup-python@v5.1.0
        with:
          python-version: ${{ env.default-python-version }}

      - name: Install PipEnv
        run: |
          pip install pipenv==2023.12.1

      - name: Sync With Repository
        run: |
          pipenv update -d
          pipenv graph

      - name: Execute Black
        run: |
          pipenv run black .

      - name: Execute ISort
        run: |
          pipenv run isort .

      - name: Execute Pre-Commit
        run: |
          pipenv run pre-commit run --all

      - name: Execute Flake8
        run: pipenv run flake8 --exclude dist,build

      - name: Execute Bandit
        run: |
          pipenv run bandit --configfile bandit.yaml -q -r ${{ github.workspace }}/${{ env.project-name }}

      - name: Execute PyLint on Source
        run: |
          pipenv run pylint ${{github.workspace}}/pymarkdown
          pipenv run pylint ${{github.workspace}}/pymarkdown/extensions
          pipenv run pylint ${{github.workspace}}/pymarkdown/extension_manager
          pipenv run pylint ${{github.workspace}}/pymarkdown/plugins
          pipenv run pylint ${{github.workspace}}/pymarkdown/plugin_manager

      - name: Execute PyLint on Tests
        run: pipenv run pylint ${{github.workspace}}/test

      - name: Execute MyPy
        run: pipenv run mypy --strict ${{ env.project-name }} stubs

      - name: Execute PyMarkdown on Current Docs
        run: pipenv run python ${{github.workspace}}/main.py --config ${{github.workspace}}/clean.json scan ${{github.workspace}} ${{github.workspace}}/docs

  doc-lint:

    name: Document Quality Analysis
    runs-on: ubuntu-latest

    steps:

      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Setup Python ${{ env.default-python-version }}
        uses: actions/setup-python@v5.1.0
        with:
          python-version: ${{ env.default-python-version }}

      - name: Install PipEnv
        run: |
          pip install pipenv==2023.12.1

      - name: Sync With Repository
        run: |
          pipenv update -d
          pipenv graph

      - name: Execute PyMarkdown on NewDocs
        run: |
          pipenv run python main.py --config newdocs/clean.json scan newdocs/src

      # - name: Execute MdFormat on Docs
      #   run: |
      #     cd newdocs
      #     pipenv run mdformat --align-semantic-breaks-in-lists --wrap 80 --check .

  scenario-tests:

    name: Scenario Tests
    strategy:
      matrix:
        # python: ["3.8", "3.9", "3.10"]
        python: ["3.8"]
        platform: [windows-latest, ubuntu-latest, macos-latest]
    runs-on: ${{ matrix.platform }}

    steps:

      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Setup Python ${{ matrix.python }}
        uses: actions/setup-python@v5.1.0
        with:
          python-version: ${{ matrix.python }}

      - name: Install PipEnv
        run: |
          pip install pipenv==2023.12.1

      - name: Sync With Repository
        run: |
          pipenv update -d
          pipenv graph
          pipenv uninstall pytest-html

      - name: Execute Tests
        run: pipenv run pytest --cov-fail-under=90 --cov --cov-branch --cov-report xml:report/coverage.xml

      - name: Archive coverage artifacts
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.platform }} Coverage
          path: |
            ./report/coverage.xml

      - name: Report Coverage
        uses: codecov/codecov-action@v4
        if: github.event_name != 'schedule'
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
        with:
          file: ./report/coverage.xml
          name: ${{ matrix.python }} - ${{ matrix.platform }}
          fail_ci_if_error: true

  packaging:

    name: Package Application
    runs-on: ubuntu-latest
    needs: [ doc-lint, lint, scenario-tests ]
    # if: github.ref == 'refs/heads/main' && github.event_name == 'push'

    steps:

      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Setup Python ${{ env.default-python-version }}
        uses: actions/setup-python@v5.1.0
        with:
          python-version: ${{ env.default-python-version }}

      - name: Install PipEnv
        run: |
          pip install pipenv==2023.12.1

      - name: Sync With Repository
        run: |
          pipenv update -d
          pipenv graph

      - name: Pyroma
        run: |
          pipenv run pyroma -q -n 10 .

      - name: Setup
        run: |
          pipenv run python setup.py sdist bdist_wheel

      - name: Twine
        run: |
          pipenv run twine check dist/*

      - name: Upload Package
        uses: actions/upload-artifact@v4
        with:
          name: my-artifact
          path: ${{github.workspace}}/dist/

      - name: Initiating Integration Tests
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: |
          ACTION_SHA=
          if [ "${{ github.event_name }}" == "pull_request" ] ; then
            ACTION_SHA=${{ github.event.pull_request.head.sha }}
          elif [ "${{ github.event_name }}" == "push" ] ; then
            ACTION_SHA=${{ github.event.head_commit.id }}
          else
            echo "$GITHUB_CONTEXT"
            ACTION_SHA=$GITHUB_SHA
          fi
          ACTION_RUN_ID=${{ github.run_id }}
          ACCESS_TOKEN=${{ secrets.INTER_PROJECT_ACCESS_TOKEN }}
          if [ -z "$ACCESS_TOKEN" ] ; then
            echo "Secret 'INTER_PROJECT_ACCESS_TOKEN' has not been set to a non-empty value."
            exit 1
          else
            echo "SHA=$ACTION_SHA"
            echo "RUN_ID=$ACTION_RUN_ID"
            echo '{"event_type": "request-integration", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'", "ref":"'"$GITHUB_REF"'", "sha": "'"$ACTION_SHA"'", "run_id" : "'"$ACTION_RUN_ID"'" }}'

            curl -X POST https://api.github.com/repos/jackdewinter/pymarkdown_test/dispatches \
              -H 'Accept: application/vnd.github.everest-preview+json' \
              -u '${{ secrets.INTER_PROJECT_ACCESS_TOKEN }}' \
              --data '{"event_type": "request-integration", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'", "ref":"'"$GITHUB_REF"'", "sha": "'"$ACTION_SHA"'", "run_id" : "'"$ACTION_RUN_ID"'" }}'
          fi


# Run the workflow that adds new tickets that are either:
# - labelled "DEPR"
# - title starts with "[DEPR]"
# - body starts with "Proposal Date" (this is the first template field)
# to the org-wide DEPR project board

name: Add newly created DEPR issues to the DEPR project board

on:
  issues:
    types: [opened]

jobs:
  routeissue:
    uses: openedx/.github/.github/workflows/add-depr-ticket-to-depr-board.yml@master
    secrets:
      GITHUB_APP_ID: ${{ secrets.GRAPHQL_AUTH_APP_ID }}
      GITHUB_APP_PRIVATE_KEY: ${{ secrets.GRAPHQL_AUTH_APP_PEM }}
      SLACK_BOT_TOKEN: ${{ secrets.SLACK_ISSUE_BOT_TOKEN }}


# This workflow runs when a comment is made on the ticket
# If the comment starts with "label: " it tries to apply
# the label indicated in rest of comment.
# If the comment starts with "remove label: ", it tries
# to remove the indicated label.
# Note: Labels are allowed to have spaces and this script does
# not parse spaces (as often a space is legitimate), so the command
# "label: really long lots of words label" will apply the
# label "really long lots of words label"

name: Allows for the adding and removing of labels via comment

on:
  issue_comment:
    types: [created]

jobs:
  add_remove_labels:
    uses: openedx/.github/.github/workflows/add-remove-label-on-comment.yml@master


Python CI

name: Python CI

on:
  push:
    branches: [master]
  pull_request:

jobs:
  build:

    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-20.04]
        python-version:
        - '3.8'
        - '3.12'

    steps:
    - uses: actions/checkout@v3
    - name: setup python
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install pip
      run: pip install -r requirements/pip.txt

    - name: Install Dependencies
      run: make dev-install

    - name: Run Tests
      run: make test


Lint Commit Messages

# Run commitlint on the commit messages in a pull request.

name: Lint Commit Messages

on:
  - pull_request

jobs:
  commitlint:
    uses: openedx/.github/.github/workflows/commitlint.yml@master


Publish package to PyPi

name: Publish package to PyPi

on:
  push:
    tags:
      - '*'

jobs:

  push:
    runs-on: ubuntu-20.04

    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: setup python
        uses: actions/setup-python@v4
        with:
          python-version: 3.8

      - name: Install pip
        run: pip install -r requirements/pip.txt

      - name: Install Dependencies
        run: pip install setuptools wheel

      - name: Build package
        run: python setup.py sdist bdist_wheel

      - name: Publish to PyPi
        uses: pypa/gh-action-pypi-publish@master
        with:
          user: __token__
          password: ${{ secrets.PYPI_UPLOAD_TOKEN }}


# This workflow runs when a comment is made on the ticket
# If the comment starts with "assign me" it assigns the author to the
# ticket (case insensitive)

name: Assign comment author to ticket if they say "assign me"
on:
  issue_comment:
    types: [created]

jobs:
  self_assign_by_comment:
    uses: openedx/.github/.github/workflows/self-assign-issue.yml@master


Support Windows Issue Creater

name: Support Windows Issue Creater
on:
  schedule:
    - cron: 0 0 1 */3 *

jobs:
  create_issue:
    name: Create Support Window Issue
    runs-on: ubuntu-20.04
    permissions:
      issues: write
    steps:
      - name: Create issue
        uses: imjohnbo/issue-bot@v3
        with:
          assignees: "usamasadiq"
          labels: "arbi-bom"
          close-previous: true
          title: "Support Window Update"
          body: |
            ### Description
            Copy the link of the current issue and add it to the [Arbi-bom GitHub Project](https://github.com/orgs/edx/projects/12).

            Follow the steps mentioned in the `repo_tools/barcalendar.py` and check following points for the [Support Window Sheet](https://docs.google.com/spreadsheets/u/2/d/11DheEtMDGrbA9hsUvZ2SEd4Cc8CaC4mAfoV8SVaLBGI/edit#gid=195838733) update.
            For reference, use the respective end of life dates from [endoflife.date](https://endoflife.date/).

            - [ ] Update the version of each dependency currently in use, if necessary
            - [ ] Delete any versions older than one prior to the one currently in use
            - [ ] Add end dates which were not previously known
            - [ ] Add new releases that we're likely to consider upgrading to
            - [ ] Do a quick review of our dependencies to see if any categories should be added or removed

        env:
          GITHUB_TOKEN: ${{ secrets.requirements_bot_github_token }}


Upgrade Requirements

name: Upgrade Requirements

on:
  schedule:
     - cron: "0 4 * * 4"
  workflow_dispatch:
     inputs:
       branch:
         description: 'Target branch to create requirements PR against'
         required: true
         default: 'master'
jobs:
   call-upgrade-python-requirements-workflow:
    with:
       branch: ${{ github.event.inputs.branch }}
       send_success_notification: false
    secrets:
       requirements_bot_github_token: ${{ secrets.REQUIREMENTS_BOT_GITHUB_TOKEN }}
       requirements_bot_github_email: ${{ secrets.REQUIREMENTS_BOT_GITHUB_EMAIL }}
       edx_smtp_username: ${{ secrets.EDX_SMTP_USERNAME }}
       edx_smtp_password: ${{ secrets.EDX_SMTP_PASSWORD }}
    uses: openedx/.github/.github/workflows/upgrade-python-requirements.yml@master


CodeQL

# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
  push:
    branches: [ master ]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ master ]
  schedule:
    - cron: '26 6 * * 6'

jobs:
  analyze:
    name: Analyze
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language: [ 'python' ]
        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
        # Learn more about CodeQL language support at https://git.io/codeql-language-support

    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

    # Initializes the CodeQL tools for scanning.
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v2
      with:
        languages: ${{ matrix.language }}
        # If you wish to specify custom queries, you can do so here or in a config file.
        # By default, queries listed here will override any specified in a config file.
        # Prefix the list here with "+" to use these queries and those in the config file.
        # queries: ./path/to/local/query, your-org/your-repo/queries@main

    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).
    # If this step fails, then you should remove it and run the build manually (see below)
    - name: Autobuild
      uses: github/codeql-action/autobuild@v2

    # ℹ Command-line programs to run using the OS shell.
    # 📚 https://git.io/JvXDl

    # ✏ If the Autobuild fails above, remove it and uncomment the following three lines
    #    and modify them (or add more) to build your code if your project
    #    uses a compiled language

    #- run: |
    #   make bootstrap
    #   make release

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v2


TraceML

name: TraceML

on:
  push:
    branches:
    - master
    - testing
jobs:
  library:
    #    if: github.event.comment.body == 'test core'
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.8, 3.9, '3.10', '3.11']
    steps:
    - run: |
        pip install -U traceml
  tests:
#    if: github.event.comment.body == 'test core'
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.8, 3.9, '3.10', '3.11']

    steps:
    - uses: actions/checkout@v4
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}
    - name: Upgrade pip
      run: |
        which python
        python -m pip install --upgrade pip
    - name: Install test dependencies
      run: pip install -r traceml/requirements/test.txt
    - name: Install master dependencies
      run: pip install -r traceml/requirements/master.txt
    - name: Install dev libraries
      run: export USE_LOCAL_PACKAGES="true" && pip install --upgrade --editable "traceml[dev]"
    - name: Test with pytest
      run: |
        cd traceml
        pytest -vv


Run all checks on Kedro

name: Run all checks on Kedro

on:
  workflow_call:
    inputs:
      branch:
        type: string
        default: ''
  push:
    branches:
      - main
      - develop
    paths-ignore:
      - "docs/**"
      - '**.md'
  pull_request:
    branches:
      - main
      - develop
    paths-ignore:
      - "docs/**"
      - '**.md'

jobs:
  unit-tests:
    strategy:
      matrix:
        os: [ windows-latest, ubuntu-latest ]
        python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
    uses: ./.github/workflows/unit-tests.yml
    with:
      os: ${{ matrix.os }}
      python-version: ${{ matrix.python-version }}
      branch: ${{ inputs.branch }}
  e2e-tests:
    strategy:
      matrix:
        os: [ windows-latest, ubuntu-latest ]
        python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
    uses: ./.github/workflows/e2e-tests.yml
    with:
      os: ${{ matrix.os }}
      python-version: ${{ matrix.python-version }}
      branch: ${{ inputs.branch }}

  lint:
    strategy:
      matrix:
        os: [ ubuntu-latest ]
        python-version: [ "3.11" ]
    uses: ./.github/workflows/lint.yml
    with:
      os: ${{ matrix.os }}
      python-version: ${{ matrix.python-version }}
      branch: ${{ inputs.branch }}

  pip-compile:
    strategy:
      matrix:
        os: [ windows-latest, ubuntu-latest ]
        python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
    uses: ./.github/workflows/pip-compile.yml
    with:
      os: ${{ matrix.os }}
      python-version: ${{ matrix.python-version }}
      branch: ${{ inputs.branch }}


Auto-merge sync PR

name: Auto-merge sync PR
# This workflow automatically merges the PRs labelled "automerge". This is a part of syncing
# of `develop` and `main` branches.

on:
  schedule:
    - cron: '*/60 * * * *' # every 60 minutes
  workflow_dispatch: # on button click

jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: ${{ secrets.GH_TAGGING_TOKEN }}

      - name: Set git email and name
        run: |
          git config --global user.email "kedro@kedro.com"
          git config --global user.name "Kedro"

      - name: Maybe merge automerge PR to `develop`
        run: ./tools/github_actions/attempt_merge_pr.sh "merge-main-to-develop" "develop" ${{ secrets.GH_TAGGING_TOKEN }}


Check Kedro version and build-publish

name: Check Kedro version and build-publish

on:
  push:
    branches:
      - main

jobs:
  check-version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - name: Install uv
        run: |
          python -m pip install "uv==0.1.32"
      - name: Install dependencies
        run: |
          uv pip install --system requests
      - name: Check version
        run: python tools/github_actions/github_actions_release.py
      - name: Set outputs
        id: version_check
        run: |
          echo "new_release=${{ env.NEW_RELEASE }}" >> $GITHUB_OUTPUT
          echo "kedro_version=${{ env.KEDRO_VERSION }}" >> $GITHUB_OUTPUT
    outputs:
      new_release: ${{ steps.version_check.outputs.new_release }}
      kedro_version: ${{ steps.version_check.outputs.kedro_version }}

  test-kedro:
    needs: check-version
    if: ${{ needs.check-version.outputs.new_release == 'true' }}
    uses: ./.github/workflows/all-checks.yml

  build-publish:
    needs: [check-version, test-kedro]
    if: |
      always() &&
      !contains(needs.*.result, 'failure') &&
      !contains(needs.*.result, 'cancelled') &&
      needs.check-version.outputs.new_release == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - name: Install uv
        run: |
          python -m pip install "uv==0.1.32"
      - name: Install dependencies
        run: |
          uv pip install --system build
      - name: Build package
        run: make package
      - name: Extract release notes from RELEASE.md
        id: extract
        run: |
          python tools/github_actions/extract_release_notes.py \
          "RELEASE.md" \
          "Release ${{needs.check-version.outputs.kedro_version}}"
      - name: Create GitHub Release
        uses: softprops/action-gh-release@v1
        with:
          tag_name: ${{needs.check-version.outputs.kedro_version}}
          name: ${{needs.check-version.outputs.kedro_version}}
          body_path: release_body.txt
          draft: false
          prerelease: false
          token: ${{ secrets.GH_TAGGING_TOKEN }}
      - name: Publish distribution to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          packages-dir: dist
          password: ${{ secrets.KEDRO_PYPI_TOKEN }}


Language Linter for Kedro Docs

name: Language Linter for Kedro Docs
on:
  workflow_dispatch:
  pull_request:
    paths:
      - "docs/**"
      - '**.md'

jobs:
  vale:
    name: runner / vale
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: errata-ai/vale-action@reviewdog
        with:
          reporter: github-pr-check


Run linter on Kedro Docs

name: Run linter on Kedro Docs

on:
  push:
    branches:
      - main
      - develop
    paths:
      - "docs/**"
      - '**.md'
  pull_request:
    branches:
      - main
      - develop
    paths:
      - "docs/**"
      - '**.md'

jobs:
  lint:
    strategy:
      matrix:
        os: [ ubuntu-latest ]
        python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
    uses: ./.github/workflows/lint.yml
    with:
      os: ${{ matrix.os }}
      python-version: ${{ matrix.python-version }}


Run e2e-tests on Kedro

name: Run e2e-tests on Kedro

on:
  workflow_call:
    inputs:
      os:
        type: string
      python-version:
        type: string
      branch:
        type: string
        default: ''

env:
  COLUMNS: 120
  LINES: 25

jobs:
  e2e-tests:
    runs-on: ${{ inputs.os }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ inputs.branch }}
      - name: Set up Python ${{inputs.python-version}}
        uses: actions/setup-python@v5
        with:
          python-version: ${{inputs.python-version}}
      - name: Cache python packages for Linux
        if: inputs.os == 'ubuntu-latest'
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{inputs.os}}-python-${{inputs.python-version}}
      - name: Cache python packages for Windows
        if: inputs.os == 'windows-latest'
        uses: actions/cache@v4
        with:
          path: ~\AppData\Local\pip\Cache
          key: ${{inputs.os}}-python-${{inputs.python-version}}
      - name: Add MSBuild to PATH
        if: inputs.os == 'windows-latest'
        uses: microsoft/setup-msbuild@v2
      - name: Install Microsoft Visual C++ Redistributable
        if: inputs.os == 'windows-latest'
        run: |
          choco install vcredist-all
      - name: Setup Hadoop binary
        if: inputs.os == 'windows-latest'
        run: |
          Invoke-WebRequest "https://github.com/steveloughran/winutils/blob/master/hadoop-2.7.1/bin/winutils.exe?raw=true" -OutFile winutils.exe
          Invoke-WebRequest "https://github.com/steveloughran/winutils/blob/master/hadoop-2.7.1/bin/hadoop.dll?raw=true" -OutFile hadoop.dll
          Move-Item .\hadoop.dll C:\Windows\System32
          New-Item -ItemType directory -Path C:\hadoop\bin
          Move-Item .\winutils.exe C:\hadoop\bin
          echo "HADOOP_HOME=C:\hadoop" | Out-File -Append -Encoding ascii -FilePath $env:GITHUB_ENV
          echo "PATH=$env:HADOOP_HOME\bin;$env:PATH" | Out-File -Append -Encoding ascii -FilePath $env:GITHUB_ENV
      - name: Install dependencies
        run: |
          pip install --upgrade pip
          pip install -U .[test]
          make install-pre-commit
      - name: pip freeze
        run: pip freeze
      - name: Run e2e tests
        run: make e2e-tests


Monthly issue metrics

name: Monthly issue metrics
on:
  workflow_dispatch:
  schedule:
    - cron: '3 2 1 * *'

permissions:
  issues: write

jobs:
  build:
    name: issue metrics
    runs-on: ubuntu-latest
    steps:

    - name: Get dates for last month
      shell: bash
      run: |
        # Get the current date
        current_date=$(date +'%Y-%m-%d')

        # Calculate the previous month
        previous_date=$(date -d "$current_date -1 month" +'%Y-%m-%d')

        # Extract the year and month from the previous date
        previous_year=$(date -d "$previous_date" +'%Y')
        previous_month=$(date -d "$previous_date" +'%m')

        # Calculate the first day of the previous month
        first_day=$(date -d "$previous_year-$previous_month-01" +'%Y-%m-%d')

        # Calculate the last day of the previous month
        last_day=$(date -d "$first_day +1 month -1 day" +'%Y-%m-%d')

        echo "$first_day..$last_day"
        echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV"

    - name: Run issue-metrics tool
      uses: github/issue-metrics@v2
      env:
        GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        SEARCH_QUERY: 'repo:kedro-org/kedro is:issue created:${{ env.last_month }} -reason:"not planned"'

    - name: Create issue
      uses: peter-evans/create-issue-from-file@v4
      with:
        title: Monthly issue metrics report
        token: ${{ secrets.GITHUB_TOKEN }}
        content-filepath: ./issue_metrics.md
        assignees: noklam


Run linters on Kedro

name: Run linters on Kedro

on:
  workflow_call:
    inputs:
      os:
        type: string
      python-version:
        type: string
      branch:
        type: string
        default: ''

jobs:
  lint:
    runs-on: ${{ inputs.os }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ inputs.branch }}
      - name: Set up Python ${{ inputs.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ inputs.python-version }}
      - name: Cache python packages
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{inputs.os}}-python-${{inputs.python-version}}
      - name: Install dependencies
        run: |
            make install-test-requirements
            make install-pre-commit
      - name: pip freeze
        run: uv pip freeze --system
      - name: Run linter
        run: make lint


Merge Gatekeeper

name: Merge Gatekeeper

on:
  pull_request:
    branches:
      - main
      - develop

jobs:
  merge-gatekeeper:
    runs-on: ubuntu-latest
    # Restrict permissions of the GITHUB_TOKEN.
    # Docs: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
    permissions:
      checks: read
      statuses: read
    steps:
      - name: Run Merge Gatekeeper
        # NOTE: v1 is updated to reflect the latest v1.x.y. Please use any tag/branch that suits your needs:
        #       https://github.com/upsidr/merge-gatekeeper/tags
        #       https://github.com/upsidr/merge-gatekeeper/branches
        uses: upsidr/merge-gatekeeper@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          timeout: 3600
          interval: 30
          ignored: 'CircleCI Pipeline, runner / vale,'


Run nightly tests on Kedro

name: Run nightly tests on Kedro

on:
  workflow_dispatch:
  schedule:
    # Run every day at midnight (UTC time)
    - cron: '0 0 * * *'

jobs:
  kedro-main-test:
    uses: ./.github/workflows/all-checks.yml
    with:
      branch: main

  kedro-develop-test:
    uses: ./.github/workflows/all-checks.yml
    with:
      branch: develop

  notify-main:
    permissions:
      issues: write
    name: Notify failed build for kedro-main
    needs: kedro-main-test
    if: ${{ !success() }}
    runs-on: ubuntu-latest
    steps:
      - uses: jayqi/failed-build-issue-action@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          label-name: "main nightly build"
          title-template: "ci: Nightly build failure on `main`"
          body-template: |
            GitHub Actions workflow [{{workflow}} #{{runNumber}}](https://github.com/{{repo.owner}}/{{repo.repo}}/actions/runs/{{runId}}) failed.
          create-label: true
          always-create-new-issue: false

  notify-develop:
    permissions:
      issues: write
    name: Notify failed build for kedro-develop
    needs: kedro-develop-test
    if: ${{ !success() }}
    runs-on: ubuntu-latest
    steps:
      - uses: jayqi/failed-build-issue-action@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          label-name: "develop nightly build"
          title-template: "ci: Nightly build failure on `develop`"
          body-template: |
            GitHub Actions workflow [{{workflow}} #{{runNumber}}](https://github.com/{{repo.owner}}/{{repo.repo}}/actions/runs/{{runId}}) failed.
          create-label: true
          always-create-new-issue: false


Run pip-compile

name: Run pip-compile

on:
  workflow_call:
    inputs:
      os:
        type: string
      python-version:
        type: string
      branch:
        type: string
        default: ''

jobs:
  pip-compile:
    runs-on: ${{ inputs.os }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ inputs.branch }}
      - name: Set up Python ${{inputs.python-version}}
        uses: actions/setup-python@v5
        with:
          python-version: ${{inputs.python-version}}
      - name: Cache python packages for Linux
        if: inputs.os == 'ubuntu-latest'
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{inputs.os}}-python-${{inputs.python-version}}
      - name: Cache python packages for Windows
        if: inputs.os == 'windows-latest'
        uses: actions/cache@v4
        with:
          path: ~\AppData\Local\pip\Cache
          key: ${{inputs.os}}-python-${{inputs.python-version}}
      - name: Add MSBuild to PATH
        if: inputs.os == 'windows-latest'
        uses: microsoft/setup-msbuild@v2
      - name: Install dependencies
        run: |
          make install-test-requirements
          make install-pre-commit
          uv pip install --system "pip-tools>=6.5"
      - name: Run pip-compile
        run: make pip-compile


Trigger kedro-starters Release

name: Trigger kedro-starters Release

on:
  release:
    types: [published]

jobs:
  trigger-release:
    runs-on: ubuntu-latest

    steps:
      - name: Get Latest Release Version
        id: get_version
        run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

      - name: Trigger release in kedro-starters
        uses: peter-evans/repository-dispatch@v2
        with:
          token: ${{ secrets.GA_STARTERS_RELEASE }}
          repository: kedro-org/kedro-starters
          event-type: release-triggered
          client-payload: '{"version": "${{ steps.get_version.outputs.version }}"}'


Sync `main` and `develop`

name: Sync `main` and `develop`
# This workflow merges commits from `main` branch to `develop` branch if the commits can be merged
# cleanly, otherwise creates a PR for the maintainers to manually resolve the conflicts.

on:
  schedule:
    - cron: '*/30 * * * *' # every 30 minutes
  workflow_dispatch: # on button click

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: ${{ secrets.GH_TAGGING_TOKEN }}

      - name: Set git email and name
        run: |
          git config --global user.email "kedro@kedro.com"
          git config --global user.name "Kedro"

      - name: Maybe merge to develop or raise a PR
        run: ./tools/github_actions/merge.sh . "main" "develop" "${{ secrets.GH_TAGGING_TOKEN }}"


Run unit-tests on Kedro

name: Run unit-tests on Kedro

on:
  workflow_call:
    inputs:
      os:
        type: string
      python-version:
        type: string
      branch:
        type: string
        default: ''
jobs:
  unit-tests:
    runs-on: ${{ inputs.os }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ inputs.branch }}
      - name: Set up Python ${{inputs.python-version}}
        uses: actions/setup-python@v5
        with:
          python-version: ${{inputs.python-version}}
      - name: Cache python packages for Linux
        if: inputs.os == 'ubuntu-latest'
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: ${{inputs.os}}-python-${{inputs.python-version}}
      - name: Cache python packages for Windows
        if: inputs.os == 'windows-latest'
        uses: actions/cache@v4
        with:
          path: ~\AppData\Local\pip\Cache
          key: ${{inputs.os}}-python-${{inputs.python-version}}
      - name: Add MSBuild to PATH
        if: inputs.os == 'windows-latest'
        uses: microsoft/setup-msbuild@v2
      - name: Install dependencies
        run: |
            make install-test-requirements
            make install-pre-commit
      - name: pip freeze
        run: uv pip freeze --system
      - name: Run unit tests
        run: make test


Build multiworld client

name: Build multiworld client

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

permissions:
  contents: read

jobs:
  build:
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v3
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -U pyinstaller
        pip install -U flask
    - name: Install pyevilemu
      run: |
        git clone https://github.com/daid/pyevilemu.git
        cd pyevilemu
        python setup.py install
    - name: Build with pyinstaller
      run: |
        cd multiworld
        pyinstaller --clean -y client.py -n multiworldclient
    - name: Upload windows dist build
      uses: actions/upload-artifact@v3
      with:
        name: multiworld-client-windows
        path: multiworld/dist/multiworldclient


Python parse test

name: Python parse test

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

permissions:
  contents: read

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python 3.10
      uses: actions/setup-python@v3
      with:
        python-version: "3.10"
    - run: python3 main.py -h
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s seashells=0 -s heartpiece=0 -s dungeon_items=keysanity --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s logic=glitched -s dungeon_items=keysanity -s heartpiece=0 -s seashells=0 -s heartcontainers=0 -s instruments=1 -s owlstatues=both -s dungeonshuffle=1 -s witch=0 -s boomerang=gift -s steal=never -s goal=random --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s logic=casual -s dungeon_items=keysy -s itempool=casual --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s textmode=none --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s overworld=dungeondive --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s overworld=nodungeons --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s overworld=alttp --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s overworld=dungeonchain --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s owlstatues=dungeon --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s owlstatues=overworld --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s owlstatues=both --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s randomstartlocation=1 --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s dungeonshuffle=1 --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s entranceshuffle=simple --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s entranceshuffle=split --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s entranceshuffle=mixed --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s entranceshuffle=wild --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s entranceshuffle=chaos --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s entranceshuffle=insane --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s entranceshuffle=madness --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s entranceshuffle=madness -s shufflejunk=1 -s shuffleannoying=1 -s shufflewater=1 --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s boss=random --output /dev/null
    - run: python3 main.py SKIP_ROM_GENERATION --timeout 120 -s miniboss=random --output /dev/null


Black format check

name: Black format check

on:
  pull_request:
    paths:
      - '.github/workflows/black_format.yml'
      - '**.py'

jobs:
  black-format-check:
    runs-on: "ubuntu-latest"
    steps:
      - uses: actions/checkout@v3.5.2
      - name: Set up Python 3.11
        uses: actions/setup-python@v4.6.0
        with:
          python-version: 3.11
      - name: Install black
        run: python -m pip install black==24.1.1
      - name: Run black
        run: black --check src


CodeQL

name: "CodeQL"

on:
  push:
    branches: [ 'main' ]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ 'main' ]
    paths:
      - '.github/workflows/codeql.yml'
      - '**.py'
      - '**.pyi'
      - '**.lock'
      - '**.js'
      - '**.ts'
  schedule:
    - cron: '10 20 * * 4'

jobs:
  analyze:
    name: Analyze
    runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
    timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language: [ 'javascript', 'python' ]
        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
        # Use only 'java' to analyze code written in Java, Kotlin or both
        # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
        # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

    steps:
    - name: Checkout repository
      uses: actions/checkout@v3

    # Initializes the CodeQL tools for scanning.
    - name: Initialize CodeQL
      uses: github/codeql-action/init@v2
      with:
        languages: ${{ matrix.language }}
        # If you wish to specify custom queries, you can do so here or in a config file.
        # By default, queries listed here will override any specified in a config file.
        # Prefix the list here with "+" to use these queries and those in the config file.

        # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
        # queries: security-extended,security-and-quality

    # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
    # If this step fails, then you should remove it and run the build manually (see below)
    - name: Autobuild
      uses: github/codeql-action/autobuild@v2

    # ℹ Command-line programs to run using the OS shell.
    # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

    #   If the Autobuild fails above, remove it and uncomment the following three lines.
    #   modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

    # - run: |
    #     echo "Run, Build Application using script"
    #     ./location_of_script_within_repo/buildscript.sh

    - name: Perform CodeQL Analysis
      uses: github/codeql-action/analyze@v2
      with:
        category: "/language:${{matrix.language}}"


Closed issue comment

name: Closed issue comment
on:
  issues:
    types: [closed]

jobs:
  add-comment:
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
      - name: Did we solve your problem?
        uses: peter-evans/create-or-update-comment@a35cf36e5301d70b76f316e867e7788a55a31dae
        with:
          issue-number: ${{ github.event.issue.number }}
          body: |
            Don't forget to [star](https://github.com/Textualize/textual) the repository!

            Follow [@textualizeio](https://twitter.com/textualizeio) for Textual updates.


FAQ issue comment

name: FAQ issue comment
on:
  issues:
    types: [opened]

jobs:
  add-comment:
    if: ${{ !contains( 'willmcgugan,darrenburns,davep,rodrigogiraoserrao', github.actor ) }}
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
      - uses: actions/checkout@v3
        with:
          ref: main
      - name: Install FAQtory
        run: pip install FAQtory
      - name: Run Suggest
        env:
          TITLE: ${{ github.event.issue.title }}
        run: faqtory suggest "$TITLE" > suggest.md
      - name: Read suggest.md
        id: suggest
        uses: juliangruber/read-file-action@v1
        with:
          path: ./suggest.md
      - name: Suggest FAQ
        uses: peter-evans/create-or-update-comment@a35cf36e5301d70b76f316e867e7788a55a31dae
        with:
          issue-number: ${{ github.event.issue.number }}
          body: ${{ steps.suggest.outputs.content }}


Test Textual module

name: Test Textual module

on:
  pull_request:
    paths:
      - ".github/workflows/pythonpackage.yml"
      - "**.py"
      - "**.pyi"
      - "**.css"
      - "**.ambr"
      - "**.lock"
      - "Makefile"

env:
  PYTEST_ADDOPTS: "--color=yes"

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

        # Python 3.9 is on macos-13 but not macos-latest (macos-14-arm64)
        # https://github.com/actions/setup-python/issues/696#issuecomment-1637587760
        exclude:
          - { python-version: "3.8", os: "macos-latest" }
          - { python-version: "3.9", os: "macos-latest" }
          - { python-version: "3.11", os: "macos-latest" }
        include:
          - { python-version: "3.8", os: "macos-13" }
          - { python-version: "3.9", os: "macos-13" }
          - { python-version: "3.11", os: "macos-13" }
    defaults:
      run:
        shell: bash
    steps:
      - uses: actions/checkout@v4.1.1
      - name: Install Poetry
        run: pipx install poetry==1.7.1
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4.7.1
        with:
          python-version: ${{ matrix.python-version }}
          cache: "poetry"
      - name: Install dependencies
        run: poetry install --no-interaction --extras syntax
        if: ${{ matrix.python-version != '3.12' }}
      - name: Install dependencies for 3.12 # https://github.com/Textualize/textual/issues/3491#issuecomment-1854156476
        run: poetry install --no-interaction
        if: ${{ matrix.python-version == '3.12' }}
      - name: Test with pytest
        run: |
          poetry run pytest tests -v --cov=./src/textual --cov-report=xml:./coverage.xml --cov-report term-missing
        if: ${{ matrix.python-version != '3.12' }}
      - name: Test with pytest for 3.12 # https://github.com/Textualize/textual/issues/3491#issuecomment-1854156476
        run: |
          poetry run pytest tests -v --cov=./src/textual --cov-report=xml:./coverage.xml --cov-report term-missing -m 'not syntax'
        if: ${{ matrix.python-version == '3.12' }}
      - name: Upload snapshot report
        if: always()
        uses: actions/upload-artifact@v3
        with:
          name: snapshot-report-textual
          path: snapshot_report.html


Pull Request Labeler

# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration.  For more information, see:
# https://github.com/actions/labeler

name: "Pull Request Labeler"
on:
- pull_request_target

jobs:
  label:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/labeler@v3
      with:
        repo-token: "${{ secrets.GITHUB_TOKEN }}"


Mark stale issues and pull requests

# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests

on:
  schedule:
  - cron: '25 10 * * *'

jobs:
  stale:

    runs-on: ubuntu-latest
    permissions:
      issues: write
      pull-requests: write

    steps:
    - uses: actions/stale@v3
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        stale-issue-message: 'Stale issue message'
        stale-pr-message: 'Stale pull request message'
        stale-issue-label: 'no-issue-activity'
        stale-pr-label: 'no-pr-activity'
        days-before-close: -1 # Disable automatic closing stale PRs


Publish Release

name: Publish Release
on:
  workflow_dispatch:  # Allow manual triggers

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Python 3
        uses: actions/setup-python@v1
        with:
          python-version: 3.8
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install twine
      - name: Build package
        run: |
          python setup.py sdist bdist_wheel
      - name: Publish package
        run: |
          twine upload --repository pypi dist/* -u __token__ -p ${{ secrets.PYPI_API_KEY }}


Run Common Tests

name: Run Common Tests
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Python 3
        uses: actions/setup-python@v1
        with:
          python-version: 3.8
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
      - name: Run unittests
        run: python -m unittest discover tests/common_tests -v


Nightly

name: Nightly
on:
  workflow_dispatch:  # Allow manual triggers
  schedule:
    - cron: 0 0 * * *

jobs:
  build:
    if: github.repository == 'sony/model_optimization' # Don't do this in forks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Python 3
        uses: actions/setup-python@v1
        with:
          python-version: 3.8

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install twine
      - name: Build nightly
        run: |
          version=$(python -c 'import model_compression_toolkit; print(model_compression_toolkit.__version__)')
          now=$(date +'%Y%m%d.%H%M%S')
          echo "nightly_version=$version.$now" >> $GITHUB_ENV
          sed -i "s/__version__ =.*/__version__ = \"$version.$now\"/g" model_compression_toolkit/__init__.py
          sed -i "s/name='model_compression_toolkit'/name='mct-nightly'/g" setup.py
          python setup.py sdist bdist_wheel
      - name: Publish nightly
        run: |
          twine upload --repository pypi dist/* --verbose -u __token__ -p ${{ secrets.PYPI_API_KEY }}
      - name: Post publish import test
        run: |
          pip install mct-nightly tensorflow torch
          version=$(python -c 'import model_compression_toolkit; print(model_compression_toolkit.__version__)')
          echo $version


Run Keras Tests

name: Run Keras Tests

on:
  workflow_call:
    inputs:
      python-version:
        required: true
        type: string
      tf-version:
        required: true
        type: string

jobs:
  run-tensorflow-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Python 3
        uses: actions/setup-python@v1
        with:
          python-version: ${{ inputs.python-version }}
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install tensorflow==${{ inputs.tf-version }}
      - name: Run unittests
        # Some tests are sensitive to memory because we use tf gradients on a multi-thread/process
        # CPU environment (https://github.com/tensorflow/tensorflow/issues/41718).
        # For this reason, if we run them in such an environment, we need to run them first non-parallel separately.
        run: |
          python -m unittest discover tests/keras_tests/pruning_tests -v
          python -m unittest discover tests/keras_tests/non_parallel_tests -v
          for script in tests/xquant_tests/keras_tests tests/keras_tests/exporter_tests tests/keras_tests/feature_networks_tests tests/keras_tests/graph_tests tests/keras_tests/layer_tests; do python -m unittest discover $script -v & pids+=($!); done; for pid in ${pids[@]}; do wait $pid || exit 1; done


Run PyTorch Tests

name: Run PyTorch Tests

on:
  workflow_call:
    inputs:
      python-version:
        required: true
        type: string
      torch-version:
        required: true
        type: string

jobs:
  run-pytorch-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Python 3
        uses: actions/setup-python@v1
        with:
          python-version: ${{ inputs.python-version }}
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install torch==${{ inputs.torch-version }} torchvision onnx onnxruntime
      - name: Run unittests
        run: |
          python -m unittest discover tests/xquant_tests/pytorch_tests -v
          python -m unittest discover tests/pytorch_tests -v


Test pip install

name: Test pip install
on:
  workflow_dispatch: # Allow manual triggers
    inputs:
      python_version:
        description: 'Python version'
        required: false
        default: '3.10'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Install Python 3
        uses: actions/setup-python@v1
        with:
          python-version: ${{  inputs.python_version  }}
      - name: Install dependencies
        run: |
          pip install -r requirements.txt
          pip install twine wheel
      - name: Build WHL file
        run: |
          version=$(python -c 'import model_compression_toolkit; print(model_compression_toolkit.__version__)')
          now=$(date +'%Y%m%d-%H%M%S')
          echo "nightly_version=$version.$now" >> $GITHUB_ENV
          sed -i "s/attr: model_compression_toolkit.__version__/$version.$now/g" setup.cfg
          sed -i "s/name='model_compression_toolkit'/name='model-compression-toolkit'/g" setup.py
          python setup.py sdist bdist_wheel
      - name: Install WHL file
        run: |
          whl_file=$(find . -iname "*.whl")
          echo $whl_file
          pip install $whl_file
          pip list
          python -c 'import model_compression_toolkit; print(model_compression_toolkit.__version__)'
      - name: Remove MCT code
        run: |
          rm -rf model_compression_toolkit
      - name: Install TF
        run: |
          pip install tensorflow==2.15.*
      - name: Run Commom Tests
        run: |
          python -m unittest discover tests/common_tests --verbose
      - name: Run Tensorflow Tests
        run: |
          python -m unittest discover tests/keras_tests --verbose
      - name: Uninstall TF and install torch
        run: |
          pip uninstall tensorflow -y
          pip install torch torchvision onnx onnxruntime onnxruntime-extensions
      - name: Run Pytorch Tests
        run: |
          python -m unittest discover tests/pytorch_tests --verbose


Check Markdown and doc links

name: Check Markdown and doc links

on:
  workflow_dispatch: # Allow manual triggers
  pull_request:
    branches:
      - main

jobs:
  link-checker:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Python 3
        uses: actions/setup-python@v1
        with:
          python-version: 3.10.*
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install requests==2.27.1
      - name: Run unittests
        run: |
          export CURL_CA_BUNDLE=''
          python -m unittest tests/doc_tests/test_docs_links.py -v


Coverage Test

name: Coverage Test
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    timeout-minutes: 80
    env:
      COVERAGE_THRESHOLD: 97
    steps:
      - uses: actions/checkout@v2
      - name: Install Python 3
        uses: actions/setup-python@v1
        with:
          python-version: '3.10'
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install coverage
      - name: Prepare TF env
        run: pip install tensorflow==2.13.*
      - name: Run tensorflow testsuite
        run: coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" unittest tests/test_suite.py -v
      - name: Prepare Torch env
        run: pip uninstall tensorflow -y && pip install torch==2.0.* torchvision onnx onnxruntime onnxruntime-extensions
      - name: Run torch testsuite
        run: coverage run --parallel-mode -m --omit "*__init__.py" --include "model_compression_toolkit/**/*.py" unittest tests/test_suite.py -v
      - name: Combine Multiple Coverage Files
        run: coverage combine
      - name: Run Coverage HTML
        run: coverage html -i --directory ./coverage_report_html
      - name: Archive code coverage results
        uses: actions/upload-artifact@v4
        with:
          name: code-coverage-report
          path: |
            coverage_report_html
      - name: Coverage Report
        run: coverage report -i --skip-covered --sort cover --fail-under $COVERAGE_THRESHOLD


Python 3.10, Keras 2.13

name: Python 3.10, Keras 2.13
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.10"
      tf-version: "2.13.*"


Python 3.9, Keras 2.13

name: Python 3.9, Keras 2.13
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.9"
      tf-version: "2.13.*"


Python 3.9, Keras 2.12

name: Python 3.9, Keras 2.12
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.9"
      tf-version: "2.12.*"


Python 3.10, Keras 2.12

name: Python 3.10, Keras 2.12
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.10"
      tf-version: "2.12.*"


Python 3.10, Pytorch 2.0

name: Python 3.10, Pytorch 2.0
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_pytorch_tests.yml
    with:
      python-version: "3.10"
      torch-version: "2.0.*"


Python 3.9, Pytorch 2.0

name: Python 3.9, Pytorch 2.0
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_pytorch_tests.yml
    with:
      python-version: "3.9"
      torch-version: "2.0.*"


Python 3.9, Keras 2.14

name: Python 3.9, Keras 2.14
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.9"
      tf-version: "2.14.*"


Python 3.10, Keras 2.14

name: Python 3.10, Keras 2.14
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.10"
      tf-version: "2.14.*"


Python 3.11, Keras 2.14

name: Python 3.11, Keras 2.14
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.11"
      tf-version: "2.14.*"


Python 3.11, Keras 2.13

name: Python 3.11, Keras 2.13
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.11"
      tf-version: "2.13.*"


Python 3.11, Keras 2.12

name: Python 3.11, Keras 2.12
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.11"
      tf-version: "2.12.*"


Run Keras Sony Custom Layers Tests

name: Run Keras Sony Custom Layers Tests
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tensorflow-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Python 3
        uses: actions/setup-python@v1
        with:
          python-version: "3.10"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install tensorflow==2.13.*
          pip install sony-custom-layers
      - name: Run unittests
        run: |
          python -m unittest discover tests/keras_tests/custom_layers_tests -v


Python 3.10, Pytorch 2.1

name: Python 3.10, Pytorch 2.1
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_pytorch_tests.yml
    with:
      python-version: "3.10"
      torch-version: "2.1.*"


Python 3.9, Pytorch 2.1

name: Python 3.9, Pytorch 2.1
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_pytorch_tests.yml
    with:
      python-version: "3.9"
      torch-version: "2.1.*"


Python 3.11, Pytorch 2.0

name: Python 3.11, Pytorch 2.0
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_pytorch_tests.yml
    with:
      python-version: "3.11"
      torch-version: "2.0.*"


Python 3.11, Pytorch 2.1

name: Python 3.11, Pytorch 2.1
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_pytorch_tests.yml
    with:
      python-version: "3.11"
      torch-version: "2.1.*"


Python 3.11, Keras 2.15

name: Python 3.11, Keras 2.15
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.11"
      tf-version: "2.15.*"


Python 3.10, Keras 2.15

name: Python 3.10, Keras 2.15
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.10"
      tf-version: "2.15.*"


Python 3.9, Keras 2.15

name: Python 3.9, Keras 2.15
on:
  workflow_dispatch: # Allow manual triggers
  schedule:
    - cron: 0 0 * * *
  pull_request:
    branches:
      - main

jobs:
  run-tests:
    uses: ./.github/workflows/run_keras_tests.yml
    with:
      python-version: "3.9"
      tf-version: "2.15.*"


Automatic Rebase

name: Automatic Rebase
on:
  push:
    branches-ignore:
      # Ignore branches automatically created by github-rebase
      - rebase-pull-request**
      - cherry-pick-rebase-pull-request**
  pull_request:
    types:
      - labeled
jobs:
  auto-rebase:
    name: AutoRebase
    runs-on: ubuntu-latest
    steps:
      - uses: actions/create-github-app-token@v1.9.0
        id: generate_token
        with:
          app-id: ${{ secrets.APP_ID }}
          private-key: ${{ secrets.APP_PRIVATE_KEY }}

      - uses: Label305/AutoRebase@v0.1
        with:
          github_token: ${{ steps.generate_token.outputs.token }}


CI

name: CI
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

concurrency:
  group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
  cancel-in-progress: true

jobs:
  commitlint:
    if: ${{ github.event_name == 'pull_request' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
        with:
          fetch-depth: 0

      - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23
        with:
          nix_path: nixpkgs=channel:nixos-unstable-small

      - uses: cachix/cachix-action@v12
        with:
          name: protoletariat
          extraPullNames: nix-community,poetry2nix

      - name: commitlint
        run: nix shell -L -f '<nixpkgs>' commitlint -c commitlint --from=${{ github.event.pull_request.base.sha }} --to=${{ github.sha }} --verbose
  pre-commit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

      - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23
        with:
          nix_path: nixpkgs=channel:nixos-unstable-small

      - uses: cachix/cachix-action@v12
        with:
          name: protoletariat
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
          extraPullNames: nix-community,poetry2nix

      - run: nix develop -c pre-commit run --all-files
  nix:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
        python-version:
          - "38"
          - "39"
          - "310"
          - "311"
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

      - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23
        with:
          nix_path: nixpkgs=channel:nixos-unstable-small

      - uses: cachix/cachix-action@v12
        with:
          name: protoletariat
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
          extraPullNames: nix-community,poetry2nix

      - name: build package and run tests
        run: nix build --print-build-logs --no-link --keep-going '.#protoletariat${{ matrix.python-version }}'

      - name: show closure info
        run: nix path-info --closure-size --human-readable --recursive '.#protoletariat${{ matrix.python-version }}'
  docker-image:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

      - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23
        with:
          nix_path: nixpkgs=channel:nixos-unstable-small

      - uses: cachix/cachix-action@v12
        with:
          name: protoletariat
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
          extraPullNames: nix-community,poetry2nix

      - name: build and load docker image
        run: nix run --print-build-logs --keep-going '.#protoletariat-image.copyToDockerDaemon'

      - run: docker images protoletariat

      - name: smoke test docker image
        run: |
          set -euo pipefail

          imagetag="$(nix eval --raw '.#protoletariat-image.imageTag')"
          docker run --rm "protoletariat:${imagetag}"
  conda-ubuntu-macos:
    strategy:
      fail-fast: false
      matrix:
        os:
          - ubuntu-latest
          - macos-latest
        python-version:
          - "3.8"
          - "3.9"
          - "3.10"
          - "3.11"
        buf:
          - buf
        include:
          - os: ubuntu-latest
            python-version: "3.9"
            buf: no-buf
          - os: macos-latest
            python-version: "3.9"
            buf: no-buf
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash -l {0}
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

      - uses: bufbuild/buf-setup-action@v1.26.1
        if: ${{ matrix.buf == 'buf' }}
        with:
          github_token: ${{ github.token }}

      - uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}

      - run: pip3 install poetry2conda poetry

      - name: Generate conda environment file
        run: |
          set -euo pipefail

          poetry2conda --dev pyproject.toml - | tee environment.yml

      - uses: conda-incubator/setup-miniconda@v2
        with:
          mamba-version: "*"
          miniforge-variant: Mambaforge
          miniforge-version: latest
          channel-priority: strict
          activate-environment: protoletariat
          python-version: ${{ matrix.python-version }}
          environment-file: environment.yml

      - run: mamba install grpc-cpp grpcio-tools
      - run: pip install .
      - run: pytest -ra
  conda-windows:
    strategy:
      fail-fast: false
      matrix:
        python-version:
          - "3.8"
          - "3.9"
          - "3.10"
          - "3.11"
        buf:
          - buf
        include:
          - python-version: "3.9"
            buf: no-buf
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

      - uses: bufbuild/buf-setup-action@v1.26.1
        if: ${{ matrix.buf == 'buf' }}
        with:
          github_token: ${{ github.token }}

      - uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}

      - run: pip3 install poetry2conda poetry

      - name: Generate conda environment file
        run: poetry2conda --dev pyproject.toml - > environment.yml

      - uses: conda-incubator/setup-miniconda@v2
        with:
          mamba-version: "*"
          miniforge-variant: Mambaforge
          miniforge-version: latest
          channel-priority: strict
          activate-environment: protoletariat
          python-version: ${{ matrix.python-version }}
          environment-file: environment.yml

      - run: mamba install grpc-cpp grpcio-tools pip
      - run: pip install .
      - run: pytest -ra
  tensorflow:
    runs-on: ubuntu-latest
    env:
      PYTHON_OUT: /tmp/tensorflow-gen
      TENSORFLOW_HOME: ${{ github.workspace }}/tensorflow
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
        with:
          path: protoletariat

      - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23
        with:
          nix_path: nixpkgs=channel:nixos-unstable-small

      - uses: cachix/cachix-action@v12
        with:
          name: protoletariat
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
          extraPullNames: nix-community,poetry2nix

      - name: Clone Tensorflow
        uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
        with:
          repository: tensorflow/tensorflow
          path: tensorflow

      - run: mkdir -p "$PYTHON_OUT"

      - name: Generate tensorflow Python proto code
        working-directory: protoletariat
        run: |
          set -euo pipefail

          mapfile -t files < <(find "$TENSORFLOW_HOME" -name '*.proto')
          nix develop -c \
            protoc \
            --python_out "$PYTHON_OUT" \
            --proto_path "$TENSORFLOW_HOME" "${files[@]}"

      - name: Test tensorflow rewriting
        working-directory: protoletariat
        run: |
          set -euo pipefail

          mapfile -t files < <(find "$TENSORFLOW_HOME" -name '*.proto')
          nix run '.#protoletariat' \
            -- \
            --in-place \
            --create-package \
            --python-out "$PYTHON_OUT" \
            protoc \
            --proto-path "$TENSORFLOW_HOME" "${files[@]}"

      - name: Check for absolute imports
        run: grep -vq -R '^import tensorflow' "$PYTHON_OUT"
  dry-release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
        with:
          fetch-depth: 0

      - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23
        with:
          nix_path: nixpkgs=channel:nixos-unstable-small

      - uses: cachix/cachix-action@v12
        with:
          name: protoletariat
          extraPullNames: nix-community,poetry2nix

      - name: Configure git info
        run: |
          set -euo pipefail

          # not incredibly important what user we use here
          #
          # we're making a commit in a temporary worktree that is thrown away
          # if the process exits successfully
          #
          # git requires user information to make commits
          git config user.name 'phillip-ground[bot]'
          git config user.email 'phillip-ground[bot]@users.noreply.github.com'

      - name: run semantic-release
        run: ./ci/release/dry_run.sh
  release:
    runs-on: ubuntu-latest
    if: ${{ github.event_name != 'pull_request' }}
    needs:
      - nix
      - conda-ubuntu-macos
      - conda-windows
      - docker-image
      - pre-commit
      - tensorflow
      - dry-release
    steps:
      - uses: actions/create-github-app-token@v1.9.0
        id: generate_token
        with:
          app-id: ${{ secrets.APP_ID }}
          private-key: ${{ secrets.APP_PRIVATE_KEY }}

      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
        with:
          fetch-depth: 0
          token: ${{ steps.generate_token.outputs.token }}

      - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23
        with:
          nix_path: nixpkgs=channel:nixos-unstable-small

      - uses: cachix/cachix-action@v12
        with:
          name: protoletariat
          extraPullNames: nix-community,poetry2nix

      - name: run semantic-release
        run: ./ci/release/run.sh
        env:
          POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
          GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}


CodeQL

name: CodeQL
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
  schedule:
    - cron: "24 22 * * 1"

concurrency:
  group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
  cancel-in-progress: true

jobs:
  analyze:
    runs-on: ubuntu-latest
    permissions:
      actions: read
      contents: read
      security-events: write

    strategy:
      fail-fast: false
      matrix:
        language:
          - python

    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
      - uses: github/codeql-action/init@v2
        with:
          languages: ${{ matrix.language }}
      - uses: github/codeql-action/autobuild@v2
      - uses: github/codeql-action/analyze@v2


Publish Docker Image

name: Publish Docker Image
on:
  release:
    types:
      - published
  workflow_dispatch:
jobs:
  publish-image:
    concurrency: publish-image
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
      - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23
        with:
          nix_path: nixpkgs=channel:nixos-unstable-small
      - uses: cachix/cachix-action@v12
        with:
          name: protoletariat
          authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
          extraPullNames: nix-community,poetry2nix
      - run: nix run --print-build-logs --keep-going '.#protoletariat-image.copyToDockerDaemon'
      - run: echo "FROM protoletariat:$(nix eval --raw '.#protoletariat-image.imageTag')" > Dockerfile
      - uses: docker/metadata-action@v4
        id: meta
        with:
          images: |
            ghcr.io/${{ github.repository_owner }}/protoletariat
          tags: |
            type=semver,pattern=v{{version}}
            type=semver,pattern=v{{major}}.{{minor}}
            type=semver,pattern=v{{major}}
            type=sha
            type=sha,format=long
      - uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}


Update Flakes

name: Update Flakes
on:
  schedule:
    - cron: "50 0 * * 0"
  workflow_dispatch:

concurrency:
  group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
  cancel-in-progress: true

jobs:
  get-flakes:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.get-flakes.outputs.matrix }}
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
      - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23
        with:
          extra_nix_config: |
            access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
      - name: generate flake matrix
        id: get-flakes
        run: |
          set -euo pipefail

          flakes="$(nix flake metadata --json | jq -rcM '.locks.nodes.root.inputs | {flake: keys}')"
          echo "matrix=$flakes" >> "$GITHUB_OUTPUT"
  flake-update:
    runs-on: ubuntu-latest
    needs:
      - get-flakes
    strategy:
      fail-fast: false
      matrix: ${{ fromJson(needs.get-flakes.outputs.matrix) }}
    steps:
      - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
      - uses: cachix/install-nix-action@6a9a9e84a173d90b3ffb42c5ddaf9ea033fad011 # v23
        with:
          nix_path: nixpkgs=channel:nixos-unstable-small
          extra_nix_config: |
            access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}

      - uses: actions/create-github-app-token@v1.9.0
        id: generate-token
        with:
          app-id: ${{ secrets.APP_ID }}
          private-key: ${{ secrets.APP_PRIVATE_KEY }}

      - uses: cpcloud/flake-update-action@v1.0.4
        with:
          dependency: ${{ matrix.flake }}
          github-token: ${{ secrets.GITHUB_TOKEN }}
          pull-request-token: ${{ steps.generate-token.outputs.token }}
          pull-request-author: "phillip-ground[bot] <phillip-ground[bot]@users.noreply.github.com>"
          pull-request-labels: dependencies,autorebase:opt-in
          automerge: true
          delete-branch: true


Set Issue Label and Assignee

name: "Set Issue Label and Assignee"
on:
  issues:
    types: [opened]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: Naturalclar/issue-action@v2.0.2
        with:
          title-or-body: "both"
          parameters: '[ {"keywords": ["niriss","NIRISS"], "labels": ["NIRISS"], "assignees": ["afeinstein20","lpcoulombe"]}, {"keywords": ["nirspec","NIRSpec","NIRSPEC"], "labels": ["NIRSpec"], "assignees": ["AarynnCarter","cpiaulet"]}, {"keywords": ["nircam","NIRCAM","NIRCam"], "labels": ["NIRCam"], "assignees": ["kevin218","meganmansfield"]}, {"keywords": ["MIRI","miri"], "labels": ["MIRI"], "assignees": ["taylorbell57","sebastian-zieba"]}, {"keywords": ["Light curve fitting"], "labels": ["LC Fit"], "assignees": ["taylorbell57","meganmansfield","evamariaa","cpiaulet"]}, {"keywords": ["Other (any stage)"], "labels": [], "assignees": ["jbrande","taylorbell57"]}]'
          github-token: "${{ secrets.GITHUB_TOKEN }}"


Build JOSS Paper Draft

name: "Build JOSS Paper Draft"
on:
  pull_request:
    types: [opened,reopened,synchronize]
  push:
    branches:
      - 'main'
      - 'releases/**'
jobs:
  paper:
    runs-on: ubuntu-latest
    name: Paper Draft
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Build draft PDF
        uses: openjournals/openjournals-draft-action@master
        with:
          journal: joss
          # This should be the path to the paper within your repo.
          paper-path: joss/paper.md
      - name: Upload
        uses: actions/upload-artifact@v4
        with:
          name: paper
          # This is the output path where Pandoc will write the compiled
          # PDF. Note, this should be the same directory as the input
          # paper.md
          path: joss/paper.pdf


Flake8 Linting

name: Flake8 Linting
on:
  pull_request:
    types: [opened,reopened,synchronize]
  push:
    branches:
      - 'main'
      - 'releases/**'
jobs:
  lint:
    name: flake8
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
        ref: ${{ github.event.pull_request.head.ref }}
    - uses: tonybajan/flake8-check-action@v1.6.0
      with:
        select: E1,E2,E3,E4,E5,E7,W6,F
        ignore: W504,W503,E704,E226,E722
        maxlinelength: 80
        repotoken: ${{ secrets.GITHUB_TOKEN }}


Pytest Testing

name: Pytest Testing
on:
  pull_request:
    types: [opened,reopened,synchronize]
  push:
    branches:
      - 'main'
      - 'releases/**'
jobs:
  test:
    name: pytest
    runs-on: 'ubuntu-latest'
    env:
      OS: 'ubuntu-latest'
      PYTHON: '3.10'
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          ref: ${{ github.event.pull_request.head.ref }}
      - uses: actions/setup-python@v5
        with:
          python-version: '3.10.14'
      - name: Setup Environment
        run: |
          python -m pip install --upgrade pip
          pip install .[jwst,hst,test]
          mkdir $HOME/crds_cache
          echo "CRDS_PATH=$HOME/crds_cache" >> $GITHUB_ENV
          echo "CRDS_SERVER_URL=https://jwst-crds.stsci.edu" >> $GITHUB_ENV
      - name: Log the current Eureka version
        run: pip show eureka
      - name: Run tests, generate coverage report
        run: pytest tests --cov=./src/eureka --cov-report=xml