rpaframework-aws

name: rpaframework-aws

on:
  push:
    branches:
      - master
    paths:
      - 'packages/aws/**'
      - '.github/workflows/aws.yaml'
  pull_request:
    branches:
      - master
    paths:
      - 'packages/aws/**'
      - '.github/workflows/aws.yaml'

defaults:
  run:
    working-directory: './packages/aws'

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        name: [
          "windows-py38",
          "windows-py39",
          "windows-py310",

          "ubuntu-py38",
          "ubuntu-py39",
          "ubuntu-py310",

          "macos-py38",
          "macos-py39",
          "macos-py310",
        ]

        include:
          - name: "windows-py38"
            python: "3.8"
            os: windows-latest
          - name: "windows-py39"
            python: "3.9"
            os: windows-latest
          - name: "windows-py310"
            python: "3.10"
            os: windows-latest
          - name: "ubuntu-py38"
            python: "3.8"
            os: ubuntu-latest
          - name: "ubuntu-py39"
            python: "3.9"
            os: ubuntu-latest
          - name: "ubuntu-py310"
            python: "3.10"
            os: ubuntu-latest
          - name: "macos-py38"
            python: "3.8"
            os: macos-latest
          - name: "macos-py39"
            python: "3.9"
            os: macos-latest
          - name: "macos-py310"
            python: "3.10"
            os: macos-latest

    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Get python version
      id: full-python-version
      shell: bash
      run: |
        echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
    - name: Set up cache
      uses: actions/cache@v1
      with:
        path: .venv
        key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Lint
      run: invoke code.lint -e
    - name: Test
      run: invoke code.test -a

  publish:
    # Only publish on master workflow runs
    if: github.ref == 'refs/heads/master'
    needs: test
    runs-on: ubuntu-latest
    env:
      INVOKE_IS_CI_CD: 1

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.9'
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Build and publish package
      if: success()
      run: |
        invoke install.setup-poetry --devpi-url ${{ secrets.devpiUrl }} --username ci --password ${{ secrets.devpiPassword }}
        invoke build.publish --ci --version=prerelease --yes-to-all


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:
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [ "master" ]
  push:
    branches: [ "master" ]
  schedule:
    # https://crontab.guru/#23_21_*_*_0
    # "At 21:23 on Sunday."
    - cron: '23 21 * * 0'

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://aka.ms/codeql-docs/language-support

    steps:
    - name: Checkout repository
      uses: actions/checkout@v3
    - name: Set up Python 3.9
      uses: actions/setup-python@v4
      with:
        python-version: 3.9.13
        cache: 'pip'
    - name: Upgrade pip, install poetry
      run: |
        python -m pip install --upgrade pip
        pip install poetry

    - name: Install dependencies
      run: |
        poetry install
        # Set the `CODEQL-PYTHON` environment variable to the Python executable
        # that includes the dependencies
        echo "CODEQL_PYTHON=$(poetry run which python)" >> $GITHUB_ENV

    # 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.

        # 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#, 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.
    # 📚 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


rpaframework-core

name: rpaframework-core

on:
  push:
    branches:
      - master
    paths:
      - 'packages/core/**'
      - '.github/workflows/core.yaml'
  pull_request:
    branches:
      - master
    paths:
      - 'packages/core/**'
      - '.github/workflows/core.yaml'

defaults:
  run:
    working-directory: './packages/core'

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        name: [
          "windows-py38",
          "windows-py39",
          "windows-py310",

          "ubuntu-py38",
          "ubuntu-py39",
          "ubuntu-py310",

          "macos-py38",
          "macos-py39",
          "macos-py310",
        ]

        include:
          - name: "windows-py38"
            python: "3.8"
            os: windows-latest
          - name: "windows-py39"
            python: "3.9"
            os: windows-latest
          - name: "windows-py310"
            python: "3.10"
            os: windows-latest
          - name: "ubuntu-py38"
            python: "3.8"
            os: ubuntu-latest
          - name: "ubuntu-py39"
            python: "3.9"
            os: ubuntu-latest
          - name: "ubuntu-py310"
            python: "3.10"
            os: ubuntu-latest
          - name: "macos-py38"
            python: "3.8"
            os: macos-latest
          - name: "macos-py39"
            python: "3.9"
            os: macos-latest
          - name: "macos-py310"
            python: "3.10"
            os: macos-latest
    env:
      INVOKE_IS_CI_CD: 1
    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Get python version
      id: full-python-version
      shell: bash
      run: |
        echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
    - name: Set up cache
      uses: actions/cache@v1
      with:
        path: .venv
        key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Lint
      run: invoke code.lint -e
    - name: Test
      run: invoke code.test -a

  publish:
    # Only publish on master workflow runs
    if: github.ref == 'refs/heads/master'
    needs: test
    runs-on: ubuntu-latest
    env:
      INVOKE_IS_CI_CD: 1

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.9'
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Build and publish package
      if: success()
      run: |
        invoke install.setup-poetry --devpi-url ${{ secrets.devpiUrl }} --username ci --password ${{ secrets.devpiPassword }}
        invoke build.publish --ci --version=prerelease --yes-to-all


rpaframework-dialogs

name: rpaframework-dialogs

on:
  push:
    branches:
      - master
    paths:
      - 'packages/dialogs/**'
      - '.github/workflows/dialogs.yaml'
  pull_request:
    branches:
      - master
    paths:
      - 'packages/dialogs/**'
      - '.github/workflows/dialogs.yaml'

defaults:
  run:
    working-directory: './packages/dialogs'

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        name: [
          "windows-py38",
          "windows-py39",
          "windows-py310",

          "ubuntu-py38",
          "ubuntu-py39",
          "ubuntu-py310",

          "macos-py38",
          "macos-py39",
          "macos-py310",
        ]

        include:
          - name: "windows-py38"
            python: "3.8"
            os: windows-latest
          - name: "windows-py39"
            python: "3.9"
            os: windows-latest
          - name: "windows-py310"
            python: "3.10"
            os: windows-latest

          - name: "ubuntu-py38"
            python: "3.8"
            os: ubuntu-latest
          - name: "ubuntu-py39"
            python: "3.9"
            os: ubuntu-latest
          - name: "ubuntu-py310"
            python: "3.10"
            os: ubuntu-latest

          - name: "macos-py38"
            python: "3.8"
            os: macos-latest
          - name: "macos-py39"
            python: "3.9"
            os: macos-latest
          - name: "macos-py310"
            python: "3.10"
            os: macos-latest

    env:
      INVOKE_IS_CI_CD: 1
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: '14'
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Lint
      run: invoke code.lint -e
    - name: Test
      run: invoke code.test -a

  publish:
    # Only publish on master workflow runs
    if: github.ref == 'refs/heads/master'
    needs: test
    runs-on: ubuntu-latest
    env:
      INVOKE_IS_CI_CD: 1

    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v1
      with:
        node-version: 14.x
        registry-url: https://npm.pkg.github.com/
        scope: '@robocorp'
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.9'
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Build and publish package
      if: success()
      run: |
        invoke install.setup-poetry --devpi-url ${{ secrets.devpiUrl }} --username ci --password ${{ secrets.devpiPassword }}
        invoke build.publish --ci --version=prerelease --yes-to-all


docs

name: docs

on:
  workflow_dispatch:
  push:
    branches:
      - master
    paths:
      - "pyproject.toml"
      - "poetry.lock"
      - "docs/source/**"
      - ".github/workflows/docs.yaml"
      - "packages/main/README.rst"

jobs:
  publish:
    runs-on: windows-latest
    env:
      SETUPTOOLS_USE_DISTUTILS: stdlib
      INVOKE_IS_CI_CD: 1
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v1
        with:
          python-version: "3.9"
      - name: Upgrade pip
        run: python -m pip install --upgrade pip
      - name: Install invocation prerequisites
        run: pip install -Ur invocations/requirements.txt
      - name: Get python version
        id: full-python-version
        shell: bash
        run: |
          echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
      - name: Set up cache
        uses: actions/cache@v3
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
      - name: Install invocation package
        run: invoke install-invocations || invoke self.install-invocations
      - name: Install dependencies
        run: invoke install
      - name: Build HTML documentation
        run: invoke docs
      - name: Build markdown documentation
        run: invoke docs.python-markdown
      - name: Publish HTML documentation
        if: success()
        uses: peaceiris/actions-gh-pages@v3
        with:
          publish_branch: gh-pages
          publish_dir: docs/build/html/
          github_token: ${{ secrets.GITHUB_TOKEN }}
          cname: rpaframework.org


rpaframework-google

name: rpaframework-google

on:
  push:
    branches:
      - master
    paths:
      - 'packages/google/**'
      - '.github/workflows/google.yaml'
  pull_request:
    branches:
      - master
    paths:
      - 'packages/google/**'
      - '.github/workflows/google.yaml'

defaults:
  run:
    working-directory: './packages/google'

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        name: [
          "windows-py38",
          "windows-py39",
          "windows-py310",

          "ubuntu-py38",
          "ubuntu-py39",
          "ubuntu-py310",

          "macos-py38",
          "macos-py39",
          "macos-py310",
        ]

        include:
          - name: "windows-py38"
            python: "3.8"
            os: windows-latest
          - name: "windows-py39"
            python: "3.9"
            os: windows-latest
          - name: "windows-py310"
            python: "3.10"
            os: windows-latest
          - name: "ubuntu-py38"
            python: "3.8"
            os: ubuntu-latest
          - name: "ubuntu-py39"
            python: "3.9"
            os: ubuntu-latest
          - name: "ubuntu-py310"
            python: "3.10"
            os: ubuntu-latest
          - name: "macos-py38"
            python: "3.8"
            os: macos-latest
          - name: "macos-py39"
            python: "3.9"
            os: macos-latest
          - name: "macos-py310"
            python: "3.10"
            os: macos-latest

    env:
      INVOKE_IS_CI_CD: 1
    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Get python version
      id: full-python-version
      shell: bash
      run: |
        echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
    - name: Set up cache
      uses: actions/cache@v1
      with:
        path: .venv
        key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Lint
      run: invoke code.lint -e
    - name: Test
      run: invoke code.test -a

  publish:
    # Only publish on master workflow runs
    if: github.ref == 'refs/heads/master'
    needs: test
    runs-on: ubuntu-latest
    env:
      INVOKE_IS_CI_CD: 1

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.9'
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Build and publish package
      if: success()
      run: |
        invoke install.setup-poetry --devpi-url ${{ secrets.devpiUrl }} --username ci --password ${{ secrets.devpiPassword }}
        invoke build.publish --ci --version=prerelease --yes-to-all


rpaframework-hubspot

name: rpaframework-hubspot

on:
  push:
    branches:
      - master
    paths:
      - 'packages/hubspot/**'
      - '.github/workflows/hubspot.yaml'
  pull_request:
    branches:
      - master
    paths:
      - 'packages/hubspot/**'
      - '.github/workflows/hubspot.yaml'

defaults:
  run:
    working-directory: './packages/hubspot'

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        name: [
          "windows-py38",
          "windows-py39",
          "windows-py310",

          "ubuntu-py38",
          "ubuntu-py39",
          "ubuntu-py310",

          "macos-py38",
          "macos-py39",
          "macos-py310",
        ]

        include:
          - name: "windows-py38"
            python: "3.8"
            os: windows-latest
          - name: "windows-py39"
            python: "3.9"
            os: windows-latest
          - name: "windows-py310"
            python: "3.10"
            os: windows-latest
          - name: "ubuntu-py38"
            python: "3.8"
            os: ubuntu-latest
          - name: "ubuntu-py39"
            python: "3.9"
            os: ubuntu-latest
          - name: "ubuntu-py310"
            python: "3.10"
            os: ubuntu-latest
          - name: "macos-py38"
            python: "3.8"
            os: macos-latest
          - name: "macos-py39"
            python: "3.9"
            os: macos-latest
          - name: "macos-py310"
            python: "3.10"
            os: macos-latest

    env:
      INVOKE_IS_CI_CD: 1
    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Get python version
      id: full-python-version
      shell: bash
      run: |
        echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
    - name: Set up cache
      uses: actions/cache@v1
      with:
        path: .venv
        key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Lint
      run: invoke code.lint -e
    - name: Test
      run: invoke code.test -a

  publish:
    # Only publish on master workflow runs
    if: github.ref == 'refs/heads/master'
    needs: test
    runs-on: ubuntu-latest
    env:
      INVOKE_IS_CI_CD: 1

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.9'
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Build and publish package
      if: success()
      run: |
        invoke install.setup-poetry --devpi-url ${{ secrets.devpiUrl }} --username ci --password ${{ secrets.devpiPassword }}
        invoke build.publish --ci --version=prerelease --yes-to-all


rpaframework

name: rpaframework

on:
  push:
    branches:
      - master
    paths:
      - 'packages/main/**'
      - '.github/workflows/main.yaml'
  pull_request:
    branches:
      - master
    paths:
      - 'packages/main/**'
      - '.github/workflows/main.yaml'

defaults:
  run:
    working-directory: './packages/main'

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        name: [
          "windows-py38",
          "windows-py39",
          "windows-py310",

          "ubuntu-py38",
          "ubuntu-py39",
          "ubuntu-py310",

          "macos-py38",
          "macos-py39",
          "macos-py310",
        ]

        include:
          - name: "windows-py38"
            python: "3.8"
            os: windows-latest
          - name: "windows-py39"
            python: "3.9"
            os: windows-latest
          - name: "windows-py310"
            python: "3.10"
            os: windows-latest
          - name: "ubuntu-py38"
            python: "3.8"
            os: ubuntu-latest
          - name: "ubuntu-py39"
            python: "3.9"
            os: ubuntu-latest
          - name: "ubuntu-py310"
            python: "3.10"
            os: ubuntu-latest
          - name: "macos-py38"
            python: "3.8"
            os: macos-13
          - name: "macos-py39"
            python: "3.9"
            os: macos-13
          - name: "macos-py310"
            python: "3.10"
            os: macos-13
    env:
      SETUPTOOLS_USE_DISTUTILS: stdlib
      INVOKE_IS_CI_CD: 1
      HUBSPOT_TOKEN: ${{ secrets.HUBSPOT_TOKEN }}
      SYSTEM_VERSION_COMPAT: "0"
    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Install xclip on linux
      if: matrix.os == 'ubuntu-latest'
      run: |
        DEBIAN_FRONTEND=noninteractive sudo apt-get update -y
        DEBIAN_FRONTEND=noninteractive sudo apt-get install xclip -y
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Get python version
      id: full-python-version
      shell: bash
      run: |
        echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
    - name: Set up cache
      uses: actions/cache@v1
      with:
        path: .venv
        key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Lint
      run: invoke code.lint -e
    - name: Test (non-linux)
      if: matrix.os != 'ubuntu-latest'
      run: invoke code.test -a
    - name: Test (linux)
      if: matrix.os == 'ubuntu-latest'
      run: |
        export XDG_SESSION_TYPE=x11
        xvfb-run --server-args="-screen 0 1280x720x24" invoke code.test
    - uses: actions/upload-artifact@v1
      if: success() || failure()
      with:
          name: ${{ matrix.os }}-py${{ matrix.python }}-test-reports
          path: packages/main/tests/results

  # publish:
  #   # Only publish on master workflow runs
  #   if: github.ref == 'refs/heads/master'
  #   needs: test
  #   runs-on: ubuntu-latest
  #   env:
  #     INVOKE_IS_CI_CD: 1
  #   steps:
  #   - uses: actions/checkout@v2
  #   - name: Set up Python
  #     uses: actions/setup-python@v1
  #     with:
  #       python-version: '3.9'
  #   - name: Upgrade pip
  #     run: python -m pip install --upgrade pip
  #   - name: Install invocation prerequisites
  #     run: pip install -Ur ../../invocations/requirements.txt
  #   - name: Install invocation package
  #     run: invoke install-invocations || invoke self.install-invocations
  #   - name: Install dependencies
  #     run: invoke install
  #   - name: Build and publish package
  #     if: success()
  #     run: |
  #       invoke install.setup-poetry --devpi-url ${{ secrets.devpiUrl }} --username ci --password ${{ secrets.devpiPassword }}
  #       invoke build.publish --ci --version=prerelease --yes-to-all


rpaframework-openai

name: rpaframework-openai

on:
  push:
    branches:
      - master
    paths:
      - 'packages/openai/**'
      - '.github/workflows/openai.yaml'
  pull_request:
    branches:
      - master
    paths:
      - 'packages/openai/**'
      - '.github/workflows/openai.yaml'

defaults:
  run:
    working-directory: './packages/openai'

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        name: [
          "windows-py38",
          "windows-py39",
          "windows-py310",

          "ubuntu-py38",
          "ubuntu-py39",
          "ubuntu-py310",

          "macos-py38",
          "macos-py39",
          "macos-py310",
        ]

        include:
          - name: "windows-py38"
            python: "3.8"
            os: windows-latest
          - name: "windows-py39"
            python: "3.9"
            os: windows-latest
          - name: "windows-py310"
            python: "3.10"
            os: windows-latest
          - name: "ubuntu-py38"
            python: "3.8"
            os: ubuntu-latest
          - name: "ubuntu-py39"
            python: "3.9"
            os: ubuntu-latest
          - name: "ubuntu-py310"
            python: "3.10"
            os: ubuntu-latest
          - name: "macos-py38"
            python: "3.8"
            os: macos-latest
          - name: "macos-py39"
            python: "3.9"
            os: macos-latest
          - name: "macos-py310"
            python: "3.10"
            os: macos-latest

    env:
      INVOKE_IS_CI_CD: 1
    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Get python version
      id: full-python-version
      shell: bash
      run: |
        echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
    - name: Set up cache
      uses: actions/cache@v1
      with:
        path: .venv
        key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Lint
      run: invoke code.lint -e
    - name: Test
      run: invoke code.test -a

  publish:
    # Only publish on master workflow runs
    if: github.ref == 'refs/heads/master'
    needs: test
    runs-on: ubuntu-latest
    env:
      INVOKE_IS_CI_CD: 1

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.9'
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Build and publish package
      if: success()
      run: |
        invoke install.setup-poetry --devpi-url ${{ secrets.devpiUrl }} --username ci --password ${{ secrets.devpiPassword }}
        invoke build.publish --ci --version=prerelease --yes-to-all


rpaframework-pdf

name: rpaframework-pdf

on:
  push:
    branches:
      - master
    paths:
      - 'packages/pdf/**'
      - '.github/workflows/pdf.yaml'
  pull_request:
    branches:
      - master
    paths:
      - 'packages/pdf/**'
      - '.github/workflows/pdf.yaml'

defaults:
  run:
    working-directory: './packages/pdf'

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        name: [
          "windows-py38",
          "windows-py39",
          "windows-py310",

          "ubuntu-py38",
          "ubuntu-py39",
          "ubuntu-py310",

          "macos-py38",
          "macos-py39",
          "macos-py310",
        ]

        include:
          - name: "windows-py38"
            python: "3.8"
            os: windows-latest
          - name: "windows-py39"
            python: "3.9"
            os: windows-latest
          - name: "windows-py310"
            python: "3.10"
            os: windows-latest
          - name: "ubuntu-py38"
            python: "3.8"
            os: ubuntu-latest
          - name: "ubuntu-py39"
            python: "3.9"
            os: ubuntu-latest
          - name: "ubuntu-py310"
            python: "3.10"
            os: ubuntu-latest
          - name: "macos-py38"
            python: "3.8"
            os: macos-latest
          - name: "macos-py39"
            python: "3.9"
            os: macos-latest
          - name: "macos-py310"
            python: "3.10"
            os: macos-latest

    env:
      INVOKE_IS_CI_CD: 1
    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Get python version
      id: full-python-version
      shell: bash
      run: |
        echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
    - name: Set up cache
      uses: actions/cache@v1
      with:
        path: .venv
        key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Lint
      run: invoke code.lint -e
    - name: Test
      run: invoke code.test -a

  publish:
    # Only publish on master workflow runs
    if: github.ref == 'refs/heads/master'
    needs: test
    runs-on: ubuntu-latest
    env:
      INVOKE_IS_CI_CD: 1

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.9'
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Build and publish package
      if: success()
      run: |
        invoke install.setup-poetry --devpi-url ${{ secrets.devpiUrl }} --username ci --password ${{ secrets.devpiPassword }}
        invoke build.publish --ci --version=prerelease --yes-to-all


daily installation tests

name: daily installation tests

on:
  schedule:
    - cron: '0 6 * * *'
  push:
    branches:
      - master
    paths:
      - '.github/workflows/pip.yaml'
  pull_request:
    branches:
      - master
    paths:
      - '.github/workflows/pip.yaml'

jobs:
  install_and_check:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 30
    strategy:
      fail-fast: false
      matrix:
        os: ["ubuntu-latest"]
        python-version: [3.7, 3.9.13, 3.10.6] #dropped: 3.8
        pip-version: [21.3.1, 22.1.2, 23.0.1] #dropped: 20.3.4
        # test the latest template on macos and windows, and other pip versions and pythons on ubuntu for speed
        # adding macos and windows to the matrix adds a bunch of running and delay because of mac and windows
        # runners being slower to allocate
        include:
          - os: macos-latest
            python-version: "3.9.13"
            pip-version: "22.1.2"
          - os: windows-latest
            python-version: "3.9.13"
            pip-version: "22.1.2"
    steps:
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
      - name: Set pip version
        run: python -m pip install --force-reinstall pip==${{matrix.pip-version}} wheel
      - name: install rpafw
        run: |
          python -m pip install rpaframework rpaframework-recognition robotframework-browser rpaframework-aws rpaframework-google rpaframework-assistant rpaframework-openai rpaframework-recognition rpaframework-windows
      - name: test install is correct
        run: |
          python -m pip check
          python -c "import RPA"
          # TODO: run whole test suite here
      - name: create pip freeze file
        run: |
          # show freeze file in CI log
          python -m pip freeze
          python -m pip freeze > requirements.txt
      - name: check freeze file
        run: |
          python -m pip install pip-audit==2.4.14
          python -m pip_audit --no-deps -r requirements.txt
        # Only run scans for latest template version from https://github.com/robocorp/template-standard/blob/master/conda.yaml
        if: ${{ matrix.python-version == '3.9.13' && matrix.pip-version == '22.1.2' }}
      - uses: actions/upload-artifact@v3
        if: success() || failure()
        with:
          name: pip_freeze_${{ matrix.python-version }}_${{ matrix.pip-version }}.txt
          path: requirements.txt


rpaframework-recognition

name: rpaframework-recognition

on:
  push:
    branches:
      - master
    paths:
      - 'packages/recognition/**'
      - '.github/workflows/recognition.yaml'
  pull_request:
    branches:
      - master
    paths:
      - 'packages/recognition/**'
      - '.github/workflows/recognition.yaml'

defaults:
  run:
    working-directory: './packages/recognition'

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        name: [
          "windows-py38",
          "windows-py39",
          "windows-py310",

          "ubuntu-py38",
          "ubuntu-py39",
          "ubuntu-py310",

          "macos-py38",
          "macos-py39",
          "macos-py310",
        ]

        include:
          - name: "windows-py38"
            python: "3.8"
            os: windows-latest
          - name: "windows-py39"
            python: "3.9"
            os: windows-latest
          - name: "windows-py310"
            python: "3.10"
            os: windows-latest
          - name: "ubuntu-py38"
            python: "3.8"
            os: ubuntu-latest
          - name: "ubuntu-py39"
            python: "3.9"
            os: ubuntu-latest
          - name: "ubuntu-py310"
            python: "3.10"
            os: ubuntu-latest
          - name: "macos-py38"
            python: "3.8"
            os: macos-latest
          - name: "macos-py39"
            python: "3.9"
            os: macos-latest
          - name: "macos-py310"
            python: "3.10"
            os: macos-latest

    env:
      INVOKE_IS_CI_CD: 1
    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Get python version
      id: full-python-version
      shell: bash
      run: |
        echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
    - name: Set up cache
      uses: actions/cache@v1
      with:
        path: .venv
        key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('poetry.lock') }}
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Lint
      run: invoke code.lint -e
    - name: Test
      run: invoke code.test

  publish:
    # Only publish on master workflow runs
    if: github.ref == 'refs/heads/master'
    needs: test
    runs-on: ubuntu-latest
    env:
      INVOKE_IS_CI_CD: 1

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.9'
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Build and publish package
      if: success()
      run: |
        invoke install.setup-poetry --devpi-url ${{ secrets.devpiUrl }} --username ci --password ${{ secrets.devpiPassword }}
        invoke build.publish --ci --version=prerelease --yes-to-all


release

name: release

on:
  workflow_dispatch:
    inputs:
      package:
        type: choice
        description: Select the package
        required: False
        default: 'rpaframework'
        options:
        - rpaframework
        - rpaframework-aws
        - rpaframework-core
        - rpaframework-dialogs
        - rpaframework-google
        - rpaframework-pdf
        - rpaframework-recognition
        - rpaframework-windows
      version:
        type: string
        description: Version number
        required: False

jobs:
  selections-done:
    runs-on: windows-latest

    steps:
      - name: Print selections to STDOUT
        run: echo  The package is ${{ github.event.inputs.package }} and version is ${{ github.event.inputs.version }}


rpaframework-windows

name: rpaframework-windows

on:
  push:
    branches:
      - master
    paths:
      - 'packages/windows/**'
      - '.github/workflows/windows.yaml'
  pull_request:
    branches:
      - master
    paths:
      - 'packages/windows/**'
      - '.github/workflows/windows.yaml'

defaults:
  run:
    working-directory: './packages/windows'

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        name: [
          "windows-py38",
          "windows-py39",
          "windows-py310",

          "ubuntu-py38",
          "ubuntu-py39",
          "ubuntu-py310",

          "macos-py38",
          "macos-py39",
          "macos-py310",
        ]

        include:
          - name: "windows-py38"
            python: "3.8"
            os: windows-latest
          - name: "windows-py39"
            python: "3.9"
            os: windows-latest
          - name: "windows-py310"
            python: "3.10"
            os: windows-latest
          - name: "ubuntu-py38"
            python: "3.8"
            os: ubuntu-latest
          - name: "ubuntu-py39"
            python: "3.9"
            os: ubuntu-latest
          - name: "ubuntu-py310"
            python: "3.10"
            os: ubuntu-latest
          - name: "macos-py38"
            python: "3.8"
            os: macos-latest
          - name: "macos-py39"
            python: "3.9"
            os: macos-latest
          - name: "macos-py310"
            python: "3.10"
            os: macos-latest

    env:
      INVOKE_IS_CI_CD: 1
      SYSTEM_VERSION_COMPAT: "0"
    steps:
    - uses: actions/checkout@v1
    - name: Set up Python ${{ matrix.python }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python }}
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Lint
      run: invoke code.lint -e
    - name: Test
      run: invoke code.test-python
      # Windows robot tests disabled in CI for now. (requires VM with UI support)

  publish:
    # Only publish on master workflow runs
    if: github.ref == 'refs/heads/master'
    needs: test
    runs-on: ubuntu-latest
    env:
      INVOKE_IS_CI_CD: 1

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: '3.9'
    - name: Upgrade pip
      run: python -m pip install --upgrade pip
    - name: Install invocation prerequisites
      run: pip install -Ur ../../invocations/requirements.txt
    - name: Install invocation package
      run: invoke install-invocations || invoke self.install-invocations
    - name: Install dependencies
      run: invoke install
    - name: Build and publish package
      if: success()
      run: |
        invoke install.setup-poetry --devpi-url ${{ secrets.devpiUrl }} --username ci --password ${{ secrets.devpiPassword }}
        invoke build.publish --ci --version=prerelease --yes-to-all


test

name: test

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version:
        - 3.7
        - 3.8
        - 3.9
        - "3.10"
        - "3.11"

    steps:
    - uses: actions/checkout@v2

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        python -m pip install --upgrade setuptools pip wheel
        pip install -e .[test]

    - name: Test build
      run: |
        python setup.py sdist bdist_wheel

    - name: Test with pytest
      run: |
        pip install -r tests/requirements.txt
        pytest --junitxml=test-results-${{ matrix.python-version }}.xml --cov=project_generator --cov-report=xml


on:
  issues:
    types: [opened]

jobs:
  thank-user:
    runs-on: ubuntu-20.04
    permissions:
      issues: write
    name: Say thanks for the Issue
    steps:
      - name: comment on the issue
        uses: hasura/comment-progress@v2.3.0
        with:
          github-token: ${{ secrets.CLI_BOT }}
          repository: 'Azure/azure-cli-extensions'
          number: ${{ github.event.issue.number }}
          id: thank-you-comment
          message: 'Thank you for opening this issue, we will look into it.'


on:
  pull_request_target:
    types: [opened]
    branches:
      - main

permissions:
  pull-requests: write

jobs:
  thank-user:
    runs-on: ubuntu-20.04
    name: Say thanks for the PR
    steps:
      - name: get message
        env:
          TITLE: ${{ github.event.pull_request.title }}
        run: |
          message=$(echo "$TITLE" | grep -oP '[{\[][^}\]]+[}\]]' | sed 's/{\|}\|\[\|\]//g')
          echo "message=$message" >> $GITHUB_ENV
          if [ -z $message ]; then
              echo "message=$(echo 'Thank you for your contribution! We will review the pull request and get back to you soon.')" >> $GITHUB_ENV
          fi
      - name: comment on the pull request
        uses: mshick/add-pr-comment@v2
        with:
          repo-token: ${{ secrets.CLI_BOT }}
          message-id: prcommentbot
          message: "${{ env.message }}"


Block PR merging on blocked labels

name: Block PR merging on blocked labels

on:
  pull_request_target:
    types: [opened, labeled, unlabeled, synchronize]
    branches:
      - main

jobs:
  block-merge:
    runs-on: ubuntu-latest
    steps:
      - name: Check blocked labels
        uses: actions/github-script@v7
        with:
          script: |
            const labels = context.payload.pull_request.labels.map(label => label.name);
            const blockedLabels = ["do-not-merge", "needs-author-feedback", "release-version-block"];

            if (labels.some(label => blockedLabels.includes(label))) {
              console.log(`It is not allowed to merge a PR with any blocked labels: ${blockedLabels}`);
              process.exit(1); // Exit with a non-zero status code to block merge
            } else {
              console.log("It is allowed to merge the PR.");
            }


Auto Review PR

name: Auto Review PR

on:
  pull_request_target:
      types: [opened, synchronize]
      branches:
        - main

permissions: {}

jobs:
  pr-code-review:
    if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-code-review') }}
    runs-on: ubuntu-latest
    permissions:
      pull-requests: read
      contents: read
    steps:
      - name: Check Init Event
        env:
           action: ${{ toJSON(github.event.action) }}
           label: ${{ toJSON(github.event.label) }}
        run: |
          echo start review module changed
      - name: Set up Python 3.11
        uses: actions/setup-python@v3
        with:
           python-version: "3.11"
      - name: Checkout CLI extension repo
        uses: actions/checkout@master
        with:
          fetch-depth: 0 # checkout all branches
          ref: ${{ github.event.pull_request.head.ref }}
          repository: ${{ github.event.pull_request.head.repo.full_name }}  # checkout pull request branch
      - name: Show workdirectory after site cloned
        run: |
           pwd
           ls
      - name: Get Diff Modules
        env:
          bash_sha: ${{ github.event.pull_request.base.sha }}
          base_branch: ${{ github.event.pull_request.base.ref }}
          base_branch_pre: "upstream"
          diff_sha: ${{ github.event.pull_request.head.sha }}
          diff_branch: ${{ github.event.pull_request.head.ref }}
          repo_full_name: ${{ github.event.pull_request.head.repo.full_name }}
        run: |
            set -x
            git --version
            git log --oneline | head -n 30
            git branch -a
            git fetch https://github.com/Azure/azure-cli-extensions.git "$base_branch":"$base_branch_pre"/"$base_branch"
            git checkout "$base_branch_pre"/"$base_branch"
            git log --oneline | head -n 30
            git checkout "$diff_branch"
            git log --oneline | head -n 30
            git --no-pager diff --name-only --diff-filter=ACMRT "$base_branch_pre"/"$base_branch"..."$diff_branch" > changed_files
            cat changed_files
            echo "changed_module_list=$(cat changed_files | grep azext_ | awk -F"azext_" '{print $1}'| awk -F"/" '{print $2}' | sort | uniq | xargs)" >> $GITHUB_ENV
      - name: Display Diff Modules
        run: |
            for mod in "$changed_module_list"
            do
              echo changed module: "${mod}"
            done
      - name: Check whether aaz-related Module
        id: check_if_aaz_used
        env:
          pr_label_list: ${{ toJson(github.event.pull_request.labels.*.name) }}
          result_path: "./review_result"
          output_file: "is_aaz_check.txt"
          survey_comment_file: "aaz_survey_comment.txt"
          base_branch: ${{ github.event.pull_request.base.ref }}
          base_branch_pre: "upstream"
        run: |
           set -ev
           mkdir ${result_path}
           git checkout "$base_branch_pre"/"$base_branch" -- scripts
           python scripts/ci/codegen_cal.py --job check
           ls ${result_path}
      - name: Archive production artifacts
        uses: actions/upload-artifact@v4
        with:
          name: review-code-output
          path: |
            review_result
          retention-days: 1
  action-on-output:
    needs: pr-code-review
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
      contents: read
    steps:
      - name: Download code review result
        uses: actions/download-artifact@v4
        with:
          name: review-code-output
      - name: Show workdirectory after result downloaded
        run: |
           pwd
           ls
      - name: Check comment file existence
        id: check_survey_comment_file
        uses: andstor/file-existence-action@v3
        with:
          files: "./aaz_survey_comment.txt"
      - name: Comment survey on the pull request
        if: steps.check_survey_comment_file.outputs.files_exists == 'true'
        uses: mshick/add-pr-comment@v2
        with:
           repo-token: ${{ secrets.GITHUB_TOKEN }}
           message-id: aazSurveyCommentBot
           message-path: |
            aaz_survey_comment.txt


name: Trigger ADO OneBranch Extension Release Pipeline

# Run this workflow every time a commit gets pushed to main
# This triggers the ADO OneBranch Extension Release Pipeline
on:
  push:
    branches:
      - main

permissions:
  contents: read
  id-token: write

jobs:
    build:
        name: Trigger Extension Release Pipeline
        runs-on: ubuntu-latest
        steps:
        - name: Harden Runner
          uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
          with:
            egress-policy: audit
        - name: Azure login
          uses: azure/login@v2
          with:
            client-id: ${{ secrets.ADO_SP_ClientID }}
            tenant-id: ${{ secrets.ADO_SP_TenantID }}
            allow-no-subscriptions: true
        - name: Azure CLI
          uses: azure/cli@v2
          env:
            ado-org: ${{secrets.ADO_ORGANIZATION}}
            ado-project: ${{secrets.ADO_PROJECT}}
            ado-pipeline-id: ${{secrets.ADO_PIPELINE_ID}}
            commit-id: ${{ github.sha }}
          with:
            inlineScript: |
              az pipelines build queue --definition-id ${{ env.ado-pipeline-id }} --organization ${{ env.ado-org }}  --project ${{ env.ado-project }} --variables commit_id=${{ env.commit-id }}


Generate Release Version and Comment PR

name: Generate Release Version and Comment PR

on:
  workflow_dispatch:
  pull_request_target:
      types: [opened, labeled, unlabeled, synchronize]
      branches:
        - main
      paths:
        - '**.py'
        - '!**/test_*.py'

permissions: {}

jobs:
  version-cal:
    if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-cal-version') && (!contains(fromJSON('["labeled", "unlabeled"]'), github.event.action) || github.event.label.name != 'release-version-block') }}
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
      contents: read
    steps:
      - name: Set Init Version Message
        env:
           action: ${{ toJSON(github.event.action) }}
           label: ${{ toJSON(github.event.label) }}
        run: |
          echo "message=$(echo 'Suggested init version: 1.0.0b1 for preview release and 1.0.0 for stable release')" >> $GITHUB_ENV
      - name: Set up Python 3.10
        uses: actions/setup-python@v3
        with:
           python-version: "3.10"
      - name: Checkout CLI extension repo
        uses: actions/checkout@master
        with:
          fetch-depth: 0 # checkout all branches
          ref: ${{ github.event.pull_request.head.ref }}
          repository: ${{ github.event.pull_request.head.repo.full_name }}  # checkout pull request branch
      - name: Show workdirectory after site cloned
        run: |
           pwd
           ls
      - name: Get Diff Files
        env:
          bash_sha: ${{ github.event.pull_request.base.sha }}
          base_branch: ${{ github.event.pull_request.base.ref }}
          base_branch_pre: "upstream"
          diff_code_file: "diff_codes.txt"
          diff_sha: ${{ github.event.pull_request.head.sha }}
          diff_branch: ${{ github.event.pull_request.head.ref }}
          repo_full_name: ${{ github.event.pull_request.head.repo.full_name }}
        run: |
            set -x
            git --version
            git log --oneline | head -n 30
            git branch -a
            git fetch https://github.com/Azure/azure-cli-extensions.git "$base_branch":"$base_branch_pre"/"$base_branch"
            git checkout "$base_branch_pre"/"$base_branch"
            git log --oneline | head -n 30
            git checkout "$diff_branch"
            git log --oneline | head -n 30
            git --no-pager diff --name-only --diff-filter=ACMRT "$base_branch_pre"/"$base_branch"..."$diff_branch" > changed_files
            cat changed_files
            cat changed_files | grep azext_ | awk -F"azext_" '{print $1}'| awk -F"/" '{print $2}' | sort | uniq > changed_modules
            echo "changed_module_list=$(cat changed_files | grep azext_ | awk -F"azext_" '{print $1}'| awk -F"/" '{print $2}' | sort | uniq | xargs)" >> $GITHUB_ENV
            git --no-pager diff --diff-filter=ACMRT "$base_branch_pre"/"$base_branch"..."$diff_branch" > "$diff_code_file"
      - name: Display Diff Modules
        run: |
            for mod in "$changed_module_list"
            do
              echo changed module: "${mod}"
            done
      - name: Checkout CLI main repo
        uses: actions/checkout@master
        with:
           repository: Azure/azure-cli
           path: ./azure-cli
      - name: Show workdirectory after cli cloned
        run: |
           pwd
           ls
      - name: Move the main repo to the same level as the extension repo
        run: |
           mv azure-cli ../
           cd ../
           pwd
           ls
      - name: Install azdev
        run: |
           python -m pip install --upgrade pip
           set -ev
           python -m venv env
           chmod +x env/bin/activate
           source ./env/bin/activate
           pip install azdev
           azdev --version
           cd ../
           azdev setup -c azure-cli -r azure-cli-extensions --debug
           az --version
           pip list -v
      - name: Gen Base and Diff Metadata
        id: get_comment_message
        env:
          pr_label_list: ${{ toJson(github.event.pull_request.labels.*.name) }}
          base_branch: ${{ github.event.pull_request.base.ref }}
          base_branch_pre: "upstream"
          diff_code_file: "diff_codes.txt"
          diff_branch: ${{ github.event.pull_request.head.ref }}
          base_meta_path: "./base_meta/"
          diff_meta_path: "./diff_meta/"
          output_file: "version_update.txt"
        run: |
           chmod +x env/bin/activate
           source ./env/bin/activate
           set -ev
           git checkout "$base_branch_pre"/"$base_branch"
           mkdir "$base_meta_path"
           for mod in "$changed_module_list"
           do
              echo changed module: "${mod}"
              azdev extension add "${mod}" && azdev command-change meta-export "${mod}" --meta-output-path ./"$base_meta_path"/ && azdev extension remove "${mod}"
           done
           git checkout "$diff_branch"
           mkdir "$diff_meta_path"
           for mod in "$changed_module_list"
           do
              echo changed module: "${mod}"
              azdev extension add "${mod}" && azdev command-change meta-export "${mod}" --meta-output-path ./"$diff_meta_path"/ && azdev extension remove "${mod}"
           done
           ls ./"$base_meta_path"/
           ls ./"$diff_meta_path"/
           git checkout "$base_branch_pre"/"$base_branch"
           python scripts/ci/release_version_cal.py
           # echo "commit_message=$(cat $output_file)" >> $GITHUB_ENV
      - name: Comment on the pull request
        uses: mshick/add-pr-comment@v2
        with:
           repo-token: ${{ secrets.GITHUB_TOKEN }}
           message-id: versioncommentbot
           message-path: |
            version_update.txt
           message-failure: |
            Please refer to [Extension version schema](https://github.com/Azure/azure-cli/blob/release/doc/extensions/versioning_guidelines.md) to update release versions.
      - name: Add block release label
        uses: actions-ecosystem/action-add-labels@v1
        if: ${{ steps.get_comment_message.outputs.BlockPR == 1 }}
        with:
          labels: release-version-block
      - name: Remove block release label
        uses: mondeja/remove-labels-gh-action@v2
        if: ${{ steps.get_comment_message.outputs.BlockPR == 0 }}
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          labels: release-version-block


Enforce PR label

name: Enforce PR label

on:
  pull_request:
    types: [labeled, unlabeled, opened, edited, synchronize]
jobs:
  enforce-label:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - name: enforce-triage-label
        uses: jupyterlab/maintainer-tools/.github/actions/enforce-label@v1


Step 1: Prep Release

name: "Step 1: Prep Release"
on:
  workflow_dispatch:
    inputs:
      version_spec:
        description: "New Version Specifier"
        default: "next"
        required: false
      branch:
        description: "The branch to target"
        required: false
      post_version_spec:
        description: "Post Version Specifier"
        required: false
      silent:
        description: "Set a placeholder in the changelog and don't publish the release."
        required: false
        type: boolean
      since:
        description: "Use PRs with activity since this date or git reference"
        required: false
      since_last_stable:
        description: "Use PRs with activity since the last stable git tag"
        required: false
        type: boolean
jobs:
  prep_release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

      - name: Prep Release
        id: prep-release
        uses: jupyter-server/jupyter_releaser/.github/actions/prep-release@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          version_spec: ${{ github.event.inputs.version_spec }}
          silent: ${{ github.event.inputs.silent }}
          post_version_spec: ${{ github.event.inputs.post_version_spec }}
          target: ${{ github.event.inputs.target }}
          branch: ${{ github.event.inputs.branch }}
          since: ${{ github.event.inputs.since }}
          since_last_stable: ${{ github.event.inputs.since_last_stable }}

      - name: "** Next Step **"
        run: |
          echo "Optional): Review Draft Release: ${{ steps.prep-release.outputs.release_url }}"


Publish Changelog

name: "Publish Changelog"
on:
  release:
    types: [published]

  workflow_dispatch:
    inputs:
      branch:
        description: "The branch to target"
        required: false

jobs:
  publish_changelog:
    runs-on: ubuntu-latest
    environment: release
    steps:
      - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

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

      - name: Publish changelog
        id: publish-changelog
        uses: jupyter-server/jupyter_releaser/.github/actions/publish-changelog@v2
        with:
          token: ${{ steps.app-token.outputs.token }}
          branch: ${{ github.event.inputs.branch }}

      - name: "** Next Step **"
        run: |
          echo "Merge the changelog update PR: ${{ steps.publish-changelog.outputs.pr_url }}"


Step 2: Publish Release

name: "Step 2: Publish Release"
on:
  workflow_dispatch:
    inputs:
      branch:
        description: "The target branch"
        required: false
      release_url:
        description: "The URL of the draft GitHub release"
        required: false
      steps_to_skip:
        description: "Comma separated list of steps to skip"
        required: false

jobs:
  publish_release:
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
    steps:
      - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

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

      - name: Populate Release
        id: populate-release
        uses: jupyter-server/jupyter_releaser/.github/actions/populate-release@v2
        with:
          token: ${{ steps.app-token.outputs.token }}
          branch: ${{ github.event.inputs.branch }}
          release_url: ${{ github.event.inputs.release_url }}
          steps_to_skip: ${{ github.event.inputs.steps_to_skip }}

      - name: Finalize Release
        id: finalize-release
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        uses: jupyter-server/jupyter_releaser/.github/actions/finalize-release@v2
        with:
          token: ${{ steps.app-token.outputs.token }}
          release_url: ${{ steps.populate-release.outputs.release_url }}

      - name: "** Next Step **"
        if: ${{ success() }}
        run: |
          echo "Verify the final release"
          echo ${{ steps.finalize-release.outputs.release_url }}

      - name: "** Failure Message **"
        if: ${{ failure() }}
        run: |
          echo "Failed to Publish the Draft Release Url:"
          echo ${{ steps.populate-release.outputs.release_url }}


Run tests

name: Run tests

on:
  push:
    branches: ["main"]
  pull_request:
  schedule:
    - cron: "0 8 * * *"

defaults:
  run:
    shell: bash -eux {0}

jobs:
  tests:
    runs-on: ${{ matrix.os }}
    timeout-minutes: 20
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        python-version: ["3.8", "3.12"]
        include:
          - os: windows-latest
            python-version: "3.9"
          - os: ubuntu-latest
            python-version: "pypy-3.8"
          - os: ubuntu-latest
            python-version: "3.11"
          - os: macos-latest
            python-version: "3.10"
    steps:
      - uses: actions/checkout@v4
      - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
      - name: Run the tests
        if: ${{ !startsWith(matrix.python-version, 'pypy') && !startsWith(matrix.os, 'windows') }}
        run: |
          hatch run cov:test --cov-fail-under 75 || hatch run test:test --lf
      - name: Run the tests on pypy
        if: ${{ startsWith(matrix.python-version, 'pypy') }}
        run: |
          hatch run test:nowarn || hatch run test:nowarn --lf
      - name: Run the tests on windows
        if: ${{ startsWith(matrix.os, 'windows') }}
        run: |
          hatch run cov:nowarn || hatch run test:nowarn --lf
      - run: hatch version 100.100.100
      - uses: jupyterlab/maintainer-tools/.github/actions/upload-coverage@v1

  coverage:
    runs-on: ubuntu-latest
    needs:
      - tests
    steps:
      - uses: actions/checkout@v4
      - uses: jupyterlab/maintainer-tools/.github/actions/report-coverage@v1
        with:
          fail_under: 77

  test_lint:
    name: Test Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
      - name: Run Linters
        run: |
          hatch run typing:test
          hatch run lint:build
          pipx run interrogate -v nbformat
          pipx run doc8 --max-line-length=200

  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
      - name: Test docs
        run: hatch run docs:build

  test_minimum_versions:
    name: Test Minimum Versions
    timeout-minutes: 20
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Base Setup
        uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
        with:
          dependency_type: minimum
      - name: Run the unit tests
        run: |
          hatch run test:nowarn || hatch run test:nowarn --lf

  test_prereleases:
    name: Test Prereleases
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Base Setup
        uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
        with:
          dependency_type: pre
      - name: Run the tests
        run: |
          hatch run test:nowarn || hatch run test:nowarn --lf

  make_sdist:
    name: Make SDist
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
      - uses: jupyterlab/maintainer-tools/.github/actions/make-sdist@v1

  test_sdist:
    runs-on: ubuntu-latest
    needs: [make_sdist]
    name: Install from SDist and Test
    timeout-minutes: 20
    steps:
      - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
      - uses: jupyterlab/maintainer-tools/.github/actions/test-sdist@v1

  check_release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Base Setup
        uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
      - name: Install Dependencies
        run: |
          pip install -e .
      - name: Check Release
        uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

  check_links:
    name: Check Links
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
      - uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
        with:
          ignore_glob: "tests/*.ipynb"

  tests_check: # This job does nothing and is only used for the branch protection
    if: always()
    needs:
      - coverage
      - test_lint
      - docs
      - test_minimum_versions
      - test_prereleases
      - check_links
      - check_release
      - test_sdist
    runs-on: ubuntu-latest
    steps:
      - name: Decide whether the needed jobs succeeded or failed
        uses: re-actors/alls-green@release/v1
        with:
          jobs: ${{ toJSON(needs) }}


tests

name: tests

on:
  pull_request:
  push:
    branches: master

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.8, 3.9, '3.10', 3.11, 3.12]

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt
        pip install .
    - name: Run flake8
      run: |
        flake8 skfem
    - name: Run sphinx build
      run: |
        sphinx-build -W -a -b html docs docs/_build
    - name: Run sphinx doctests
      run: |
        sphinx-build -W -a -b doctest docs docs/_build
    - name: Run mypy
      run: |
        mypy skfem
    - name: Run pytest
      run: |
        pytest


Packages Static Check

name: Packages Static Check

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v3
        with:
          python-version: 3.8

      - name: Install Tools
        shell: bash
        run: |
          sudo apt-get update && sudo apt-get install python-tk
          sudo apt-get install scons rxvt-unicode
          sudo apt-get -qq install gcc-multilib libc6:i386 libgcc1:i386 gcc-4.6-base:i386 libstdc++5:i386 libstdc++6:i386 libsdl-dev || true
          pip install scons requests tqdm wget html-table kconfiglib

      - name: Packages Static Check
        shell: bash
        run: |
          BASE_ROOT=${{ github.workspace }} && cd .. && mkdir packages_temp && cp packages -R packages_temp && mv packages_temp packages && cd packages/packages_temp  && echo "source \"\$PKGS_DIR/packages/Kconfig\"" > Kconfig
          cd ${BASE_ROOT} && export PKGS_ROOT=${BASE_ROOT}/packages_temp && git clone --depth=1 --branch=master https://github.com/RT-Thread/rt-thread.git rt-thread && export RTT_ROOT=${BASE_ROOT}/rt-thread || true
          export TERM=xterm
          cd ${RTT_ROOT}/bsp/qemu-vexpress-a9
          python -c 'import kconfiglib; kconfiglib.standard_kconfig()'
          cd ${PKGS_ROOT}/packages && python ci.py
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


Packages Test

name: Packages Test

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
    push:
        branches:
          - master
    pull_request:
        branches:
            - master
    workflow_dispatch:
    # Runs at 00:00 UTC on the 1, 16 and 31th of every month、
    schedule:
        - cron:  '0 0 */15 * *'

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
    pages: write      # to deploy to Pages
    id-token: write   # to verify the deployment originates from an appropriate source

concurrency:
    group: pkgs-test
    cancel-in-progress: false # wait for finish.

jobs:
    change_pull_request:
        if: ${{ github.event_name == 'pull_request' }}
        uses: RT-Thread/pkgs-test/.github/workflows/pkgs-action.yml@main
        with:
            package-append-res: true
            deploy-pages: false

    change_push:
        if: ${{ github.event_name == 'push' }}
        uses: RT-Thread/pkgs-test/.github/workflows/pkgs-action.yml@main
        with:
            package-append-res: true
            deploy-pages: true

    master-stm32h750-artpi-test:
        if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}}
        uses: RT-Thread/pkgs-test/.github/workflows/pkgs-action.yml@main
        with:
            bsps: stm32/stm32h750-artpi:sourcery-arm
            rt-thread-versions: branch:master
            package-append-res: true
            package-test-all: true
            deploy-pages: true
            check-errors: false

    master-k210-test:
        if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}}
        needs: master-stm32h750-artpi-test
        uses: RT-Thread/pkgs-test/.github/workflows/pkgs-action.yml@main
        with:
            bsps: k210:sourcery-riscv-none-embed
            rt-thread-versions: branch:master
            package-append-res: true
            package-test-all: true
            deploy-pages: true
            check-errors: false

    master-qemu-vexpress-a9-test:
        if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}}
        needs: master-k210-test
        uses: RT-Thread/pkgs-test/.github/workflows/pkgs-action.yml@main
        with:
            bsps: qemu-vexpress-a9:sourcery-arm
            rt-thread-versions: branch:master
            package-append-res: true
            package-test-all: true
            deploy-pages: true
            check-errors: false

    v4_1_1-stm32h750-artpi-test:
        needs: master-qemu-vexpress-a9-test
        if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}}
        uses: RT-Thread/pkgs-test/.github/workflows/pkgs-action.yml@main
        with:
            bsps: stm32/stm32h750-artpi:sourcery-arm
            rt-thread-versions: tag:v4.1.1
            package-append-res: true
            package-test-all: true
            deploy-pages: true
            check-errors: false

    v4_1_1-k210-test:
        if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}}
        needs: v4_1_1-stm32h750-artpi-test
        uses: RT-Thread/pkgs-test/.github/workflows/pkgs-action.yml@main
        with:
            bsps: k210:sourcery-riscv-none-embed
            rt-thread-versions: tag:v4.1.1
            package-append-res: true
            package-test-all: true
            deploy-pages: true
            check-errors: false

    v4_1_1-qemu-vexpress-a9-test:
        if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}}
        needs: v4_1_1-k210-test
        uses: RT-Thread/pkgs-test/.github/workflows/pkgs-action.yml@main
        with:
            bsps: qemu-vexpress-a9:sourcery-arm
            rt-thread-versions: tag:v4.1.1
            package-append-res: true
            package-test-all: true
            deploy-pages: true
            check-errors: false


cffconvert

name: cffconvert

on:
  push:
    paths:
      - CITATION.cff

jobs:
  validate:
    name: "cffconvert"
    runs-on: ubuntu-latest
    steps:
      - name: Install eossr
        run: |
          pip install eossr

      - name: Check out a copy of the repository
        uses: actions/checkout@v4

      - name: Check whether the citation metadata from CITATION.cff is valid
        uses: citation-file-format/cffconvert-github-action@2.0.0
        with:
          args: "--validate"

      - name: Convert CITATION.cff to Codemeta metadata format
        uses: citation-file-format/cffconvert-github-action@2.0.0
        if: success()
        with:
          args: "--infile ./CITATION.cff --format codemeta --outfile codemeta.json"

      - name: Fix codemeta.json
        if: success()
        run: |
          cd dev && python codemeta.py

      - name: Validate codemeta.json
        if: success()
        run: |
          eossr-metadata-validator codemeta.json

      - name: commit changes
        uses: stefanzweifel/git-auto-commit-action@v5.0.1
        if: success()
        with:
          commit_author: GitHub Actions <actions@github.com>
          commit_message: commit metadata files


CI

name: CI
on: [push, pull_request]

jobs:
  lint:
    name: Black check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: psf/black@stable
        with:
          version: "24.2.0"
  ci-runs:
    name: ${{ matrix.os }}, ${{ matrix.tox_env }}
    runs-on: ${{ matrix.os }}
    continue-on-error: ${{ matrix.allowed_fail }}
    env:
      PYTEST_ADDOPTS: --color=yes -n auto --dist=loadscope
    strategy:
      fail-fast: true
      matrix:
        include:
          - os: ubuntu-latest
            python: '3.11'
            tox_env: 'py311-test-alldeps_noray'
            gammapy_data_path: /home/runner/work/gammapy/gammapy/gammapy-datasets/dev
            allowed_fail: false
          - os: ubuntu-latest
            python: '3.10'
            tox_env: 'py310-test-alldeps-cov'
            gammapy_data_path: /home/runner/work/gammapy/gammapy/gammapy-datasets/dev
            allowed_fail: false
          - os: macos-latest
            python: '3.11'
            tox_env: 'py311-test'
            gammapy_data_path: /Users/runner/work/gammapy/gammapy/gammapy-datasets/dev
            allowed_fail: false
          - os: macos-14
            python: '3.11'
            tox_env: 'py311-test'
            allowed_fail: false
          - os: windows-latest
            python: '3.11'
            tox_env: 'py311-test-alldeps_noray'
            gammapy_data_path:  D:\a\gammapy\gammapy\gammapy-datasets\dev
            allowed_fail: false
          - os: ubuntu-latest
            python: '3.12'
            tox_env: 'py312-test-alldeps_noray'
            gammapy_data_path: /home/runner/work/gammapy/gammapy/gammapy-datasets/dev
            allowed_fail: false
          - os: ubuntu-latest
            python: '3.10'
            tox_env: 'py310-test'
            allowed_fail: false
          - os: ubuntu-latest
            python: '3.10'
            tox_env: 'codestyle'
            allowed_fail: false
          - os: ubuntu-latest
            python: '3.9'
            tox_env: 'py39-test-alldeps_noray-astropy50-numpy121'
            allowed_fail: false
          - os: ubuntu-latest
            python: '3.9'
            tox_env: 'oldestdeps'
            allowed_fail: false
          - os: ubuntu-latest
            python: '3.11'
            tox_env: 'devdeps'
            allowed_fail: true
    steps:
      - name: Check out repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Set up Python ${{ matrix.python }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}
      - name: Install base dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install tox
      - name: download datasets
        if: ${{ matrix.gammapy_data_path }}
        run: |
          python -m pip install tqdm requests
          python -m pip install -e .
          gammapy download datasets
      - name: Print Python, pip, and tox versions
        run: |
          python -c "import sys; print(f'Python {sys.version}')"
          python -c "import pip; print(f'pip {pip.__version__}')"
          python -c "import tox; print(f'tox {tox.__version__}')"
      - name: Run tests
        if: ${{ !matrix.gammapy_data_path }}
        run: tox -e ${{ matrix.tox_env }} -- -n auto
      - name: Run tests with data
        if: ${{ matrix.gammapy_data_path }}
        env:
          GAMMAPY_DATA: ${{ matrix.gammapy_data_path}}
        run: tox -e ${{ matrix.tox_env }} -- -n auto
      - name: Upload coverage to codecov
        if: "contains(matrix.tox_env, '-cov')"
        uses: codecov/codecov-action@v4
        with:
          file: ./coverage.xml
          verbose: true
  sphinx:
    name: Linux python 3.9 sphinx all-deps
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash -l {0}
    env:
      PYTEST_ADDOPTS: --color=yes -n auto --dist=loadscope
      GAMMAPY_DATA: /home/runner/work/gammapy/gammapy/gammapy-datasets/dev
    steps:
      - name: Check out repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Set up Python ${{ matrix.python }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}
      - name: Install base dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install tox
      - name: download datasets
        run: |
          python -m pip install tqdm requests
          python -m pip install -e .
          gammapy download datasets
      - name: test build docs
        run: |
          tox -e build_docs -- -j auto
      - name: check links
        continue-on-error: true
        run: |
          tox -e linkcheck -- -j auto
  conda-build:
    name: Linux python 3.9 conda-build all-deps
    runs-on: ubuntu-latest
    defaults:
      run:
        shell: bash -l {0}
    steps:
      - name: checkout repo
        uses: actions/checkout@v4
      - name: create and activate env
        uses: mamba-org/setup-micromamba@v1
        with:
          environment-file: environment-dev.yml
          cache-downloads: true
      - name: install gammapy
        run: |
          pip install -e .
      - name: test conda build
        run: |
          make clean
          conda install conda-build
          conda info
          conda --version
          conda build --version
          python setup.py bdist_conda


Build dev docs

name: Build dev docs
on: push

jobs:
  dispatch-docs:
    if: github.repository_owner == 'gammapy'
    runs-on: ubuntu-latest
    steps:
      - name: Dispatch Gammapy Docs
        uses: peter-evans/repository-dispatch@v3
        with:
          token: ${{ secrets.REMOTE_DISPATCH }}
          repository: gammapy/gammapy-docs
          event-type: dev-docs


Run profiler on benchmarks

name: Run profiler on benchmarks
on:
  pull_request:
    types:
      - closed
jobs:
  dispatch-benchmarks:
    if: ${{ (github.repository_owner == 'gammapy') && (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'trigger-benchmarks')) }}
    runs-on: ubuntu-latest
    steps:
      - name: Dispatch Gammapy Benchmarks
        uses: peter-evans/repository-dispatch@v3
        with:
          token: ${{ secrets.REMOTE_DISPATCH }}
          repository: gammapy/gammapy-benchmarks
          event-type: dev-benchmarks


Greetings

name: Greetings

on: [pull_request, issues]

jobs:
  greeting:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/first-interaction@v1
      continue-on-error: true
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        issue-message: 'Merci! We will respond to your issue shortly. In the meantime, try `import gammapy; gammapy.song()`'
        pr-message: 'Graçias! We will review your pull request shortly. In the meantime, try `import gammapy; gammapy.song(karaoke=True)`'


Release

name: Release

on:
  push:
    tags-ignore:
      - 'v*.dev'

jobs:
  release-pypi:
    if: github.repository_owner == 'gammapy'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Update tags
        run: git fetch --tags --force
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: 3.9
      - name: Install dependencies
        run: |
          python --version
          pip install -U build
          python -m build --sdist
      - name: Publish package
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          user: __token__
          password: ${{ secrets.PYPI_TOKEN }}

  release-github:
    if: github.repository_owner == 'gammapy' && !contains(github.ref_name, 'rc')
    needs: release-pypi
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Release
        uses: softprops/action-gh-release@v2
        with:
          body: |
            Gammapy is a Python package for gamma-ray astronomy. See [changelog for this release](https://github.com/gammapy/gammapy/blob/main/docs/release-notes/${{ github.ref_name }}.rst).

  dispatch-docs:
    if: github.repository_owner == 'gammapy'
    needs: release-pypi
    runs-on: ubuntu-latest
    steps:
      - name: Dispatch Gammapy Docs
        uses: peter-evans/repository-dispatch@v3
        with:
          token: ${{ secrets.REMOTE_DISPATCH }}
          repository: gammapy/gammapy-docs
          event-type: release
          client-payload: '{"release": "${{ github.ref_name }}"}'

  dispatch-webpage:
    if: github.repository_owner == 'gammapy'
    needs: release-github
    runs-on: ubuntu-latest
    steps:
      - name: Dispatch Gammapy Webpage
        uses: peter-evans/repository-dispatch@v3
        with:
          token: ${{ secrets.REMOTE_DISPATCH }}
          repository: gammapy/gammapy-webpage
          event-type: release
          client-payload: '{"release": "${{ github.ref_name }}"}'


CI/CD

name: CI/CD

on:
  pull_request:  # any pull request
  push:
    branches:
      - master

defaults:
  run:
    shell: bash

env:
  AWS_DEFAULT_OUTPUT: json
  AWS_DEFAULT_REGION: us-east-1
  AWS_MAX_ATTEMPTS: 20  # retry attempts for AWS API calls
  AWS_RETRY_MODE: adaptive  # defaults to "legacy"; this handles more errors
  NODE_VERSION: '18'
  PYTEST_ADDOPTS: --color=yes
  RUNWAY_TEST_NAMESPACE: gh-${{ github.run_id }}
  PIPENV_IGNORE_VIRTUALENVS: '1'

jobs:
  changes:
    runs-on: ubuntu-latest
    outputs:
      infra-test: ${{ steps.filter.outputs.infrastructure-test }}
      infra-test-alt: ${{ steps.filter.outputs.infrastructure-test-alt }}
    steps:
      - uses: actions/checkout@v4  # not needed for pull_request
        if: |
          github.event_name == 'push'
      - uses: dorny/paths-filter@v3  # cspell:ignore dorny
        id: filter
        with:
          filters: |
            infrastructure-test:
              - 'infrastructure/blueprints/admin_user.py'
              - 'infrastructure/blueprints/cfngin_bucket.py'
              - 'infrastructure/blueprints/prevent_privilege_escalation.py'
              - 'infrastructure/blueprints/test_runner_boundary.py'
              - 'infrastructure/blueprints/test_runner_user.py'
              - 'infrastructure/test/common/**'
            infrastructure-test-alt:
              - 'infrastructure/blueprints/admin_role.py'
              - 'infrastructure/blueprints/cfngin_bucket.py'
              - 'infrastructure/blueprints/prevent_privilege_escalation.py'
              - 'infrastructure/blueprints/test_runner_boundary.py'
              - 'infrastructure/test-alt/common/**'
  deploy-test-infrastructure:
    name: Deploy Test Infrastructure
    environment: test
    concurrency: test-infrastructure
    needs: changes
    if: |
      github.repository == 'onicagroup/runway' &&
      (needs.changes.outputs.infra-test == 'true' || needs.changes.outputs.infra-test-alt == 'true')
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        id: setup-python
        with:
          python-version: 3.9
      - uses: Gr1N/setup-poetry@v9
      - uses: actions/cache@v4
        id: cache
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
      - name: Ensure Cache Is Healthy
        if: runner.os != 'Windows' && steps.cache.outputs.cache-hit == 'true'
        run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
      - run: poetry install --extras docs -vv
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.DEPLOY_AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - run: make deploy test
        working-directory: infrastructure
      - run: make deploy test-alt
        working-directory: infrastructure
  lint-python:
    name: Lint Python
    strategy:
      matrix:
        python-version: [3.9, '3.10', '3.11']
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    env:
      # populating AWS creds with fake values
      AWS_ACCESS_KEY_ID: test
      AWS_SECRET_ACCESS_KEY: test
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v4
      - name: Install Node
        uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
      - uses: actions/setup-python@v5
        id: setup-python
        with:
          python-version: ${{ matrix.python-version }}
      - uses: Gr1N/setup-poetry@v9
      - uses: actions/cache@v4
        id: cache
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
      - name: Ensure Cache Is Healthy
        if: runner.os != 'Windows' && steps.cache.outputs.cache-hit == 'true'
        run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
      - run: poetry install --extras docs -vv
      - name: Install Node Dependencies
        run: make npm-ci
      - name: Run Linters
        run: make lint
  pre-commit:
    name: pre-commit
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.10']
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        id: setup-python
        with:
          python-version: ${{ matrix.python-version }}
      - uses: Gr1N/setup-poetry@v9
      - uses: actions/cache@v4
        id: cache
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
      - name: Ensure Cache Is Healthy
        if: runner.os != 'Windows' && steps.cache.outputs.cache-hit == 'true'
        run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
      - run: poetry install --extras docs -vv
      - uses: pre-commit/action@v3.0.1
  test-functional:
    name: Functional Tests
    needs: deploy-test-infrastructure
    # will fail if run from forks
    if: |
      always() &&
      github.repository == 'onicagroup/runway' &&
      github.actor != 'dependabot[bot]' &&
      (needs.deploy-test-infrastructure.result == 'success' || needs.deploy-test-infrastructure.result == 'skipped')
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
      - uses: actions/setup-python@v5
        id: setup-python
        with:
          python-version: '3.10'
      - uses: Gr1N/setup-poetry@v9
      - uses: actions/cache@v4
        id: cache
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
      - name: Ensure Cache Is Healthy
        if: runner.os != 'Windows' && steps.cache.outputs.cache-hit == 'true'
        run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
      - run: poetry install --extras docs -vv
      - name: Install Ubuntu Dependencies
        run: |
          sudo apt update -y
          sudo apt install -y default-libmysqlclient-dev libxml2-dev libxmlsec1-dev libxmlsec1-openssl pkg-config
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          aws-access-key-id: ${{ secrets.TEST_RUNNER_AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.TEST_RUNNER_AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Run Tests
        run: make test-functional
  test-python:
    name: Test Python
    strategy:
      matrix:
        python-version: [3.9, '3.10', '3.11']
        os: [ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    env:
      # populating AWS creds with fake values
      AWS_ACCESS_KEY_ID: test
      AWS_SECRET_ACCESS_KEY: test
    steps:
      - name: Checkout Repo (complete)
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Install Node
        uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
      - uses: actions/setup-python@v5
        id: setup-python
        with:
          python-version: ${{ matrix.python-version }}
      - uses: Gr1N/setup-poetry@v9
      - uses: actions/cache@v4
        id: cache
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
      - name: Ensure Cache Is Healthy
        if: steps.cache.outputs.cache-hit == 'true'
        run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
      - run: poetry install --extras docs -vv
      - name: Install Node Dependencies
        run: make npm-install
      - name: Configure Pagefile  # avoid MemoryError during tests
        if: runner.os == 'Windows'
        uses: al-cheb/configure-pagefile-action@v1.4  # cspell:ignore cheb
        with:
          minimum-size: 16GB
          maximum-size: 16GB
          disk-root: 'C:'
      - name: Run Integration & Unit Tests
        # assertions assume linux so some fail when run on windows
        run: make test cov-xml
      - name: Upload to Codecov
        uses: codecov/codecov-action@v4.5.0
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          fail_ci_if_error: true
  build-pypi:
    name: Build PyPi 📦
    needs:
      - pre-commit
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo (complete)
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-python@v5
        id: setup-python
        with:
          python-version: 3.9
      # Remove apt repos that are known to break from time to time
      # See https://github.com/actions/virtual-environments/issues/323
      - name: Remove broken apt repos (ubuntu)
        run: |
          for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
      - name: Install Dependencies (ubuntu)
        run: sudo apt-get update && sudo apt-get install sed -y
      - uses: Gr1N/setup-poetry@v9
      - uses: actions/cache@v4
        id: cache
        with:
          path: .venv
          key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
      - name: Ensure Cache Is Healthy
        if: runner.os != 'Windows' && steps.cache.outputs.cache-hit == 'true'
        run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
      - run: poetry install --extras docs -vv
      - name: Run Build
        run: make build
      - name: Upload Distribution Artifact
        uses: actions/upload-artifact@v4
        with:
          name: pypi-dist
          path: dist


Label Maker

# Manage the labels of a GitHub repository as code.
name: Label Maker

on:
  push:
    paths:
      - .github/workflows/label-maker.yml
      - .github/labels.yml

jobs:
  label-maker:
    # Skip running the job from forks.
    if: github.repository == 'onicagroup/runway' && github.actor != 'dependabot[bot]'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Run Label Maker
        uses: crazy-max/ghaction-github-labeler@v5
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          yaml-file: .github/labels.yml
          skip-delete: false
          dry-run: ${{ github.ref != 'refs/heads/master' }}


PR Target (opened)

name: PR Target (opened)

on:
  pull_request_target:
    types:
      - opened
      - reopened

jobs:
  assign-author:
    name: Assign Author to PR
    if: github.actor != 'dependabot[bot]'
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/assign-author@v1  # cspell:ignore technote
  label-pr:
    name: Label PR
    runs-on: ubuntu-latest
    steps:
      - uses: release-drafter/release-drafter@v6.0.0
        with:
          disable-releaser: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


PR

name: PR

on:
  pull_request:

jobs:
  branch-name:
    name: Enforce Branch Name
    runs-on: ubuntu-latest
    steps:
      - uses: deepakputhraya/action-branch-name@v1.0.0  # cspell:ignore deepakputhraya
        with:
          regex: ([a-z])+\/([a-zA-Z0-9\-\_])+
          allowed_prefixes: bugfix,chore,depend,dependabot,docs,feat,feature,fix,hotfix,maint,maintain,maintenance,release
          ignore: develop,master,release,v0_47_fixes