Format migration notebooks JSON. #3168
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Test Library CI (main)" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request_target: | |
| # Note: `pull_request_target` ensures that the tests run in the context of the `main` branch, not in the user's fork. | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| test: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| runs-on: ubuntu-latest | |
| env: | |
| VENV_PATH: .venv | |
| # Previosly we had: | |
| # if workflow_dispatch: True | |
| # if pull_request_target: False | |
| # if push: nothing, which translates to False | |
| SHOULD_TEST_ALL_FILES: ${{ github.event_name == 'workflow_dispatch' }} | |
| steps: | |
| # | |
| # Setup Repository | |
| # | |
| - name: Checkout (push / workflow_dispatch) | |
| if: github.event_name != 'pull_request_target' | |
| uses: actions/checkout@v4 | |
| - name: Checkout PR head (pull_request_target) | |
| if: github.event_name == 'pull_request_target' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| persist-credentials: false | |
| # | |
| # Setup Python | |
| # | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Get latest classiq version for cache key | |
| id: classiq-version | |
| shell: python | |
| run: | | |
| import urllib.request | |
| import json | |
| import os | |
| url = 'https://pypi.org/pypi/classiq/json' | |
| with urllib.request.urlopen(url) as response: | |
| data = json.loads(response.read()) | |
| version = data['info']['version'] | |
| output_file = os.environ['GITHUB_OUTPUT'] | |
| with open(output_file, 'a') as f: | |
| f.write(f"LATEST_CLASSIQ_VERSION={version}\n") | |
| # The caching we do follows from | |
| # https://stackoverflow.com/questions/59127258/how-can-i-use-pip-cache-in-github-actions | |
| - uses: actions/cache@v4 | |
| id: cache-venv | |
| with: | |
| path: ${{ env.VENV_PATH }} | |
| key: ${{ runner.os }}-venv-classiq-${{steps.classiq-version.outputs.LATEST_CLASSIQ_VERSION}}-requirements-${{ hashFiles('**/requirements*.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-venv-classiq-${{steps.classiq-version.outputs.LATEST_CLASSIQ_VERSION}} | |
| - name: Enter venv | |
| run: echo "$PWD/${{ env.VENV_PATH }}/bin" >> $GITHUB_PATH | |
| - name: Install dependencies | |
| if: steps.cache-venv.outputs.cache-hit != 'true' | |
| run: | | |
| set -e | |
| if [ ! -d "${{ env.VENV_PATH }}" ]; then | |
| python -m venv "${{ env.VENV_PATH }}" | |
| hash -r # refresh memory of last process location, to use python from venv | |
| fi | |
| python -m pip install -U pip | |
| python -m pip install -U -r requirements.txt -r requirements_tests.txt | |
| - name: Install couenne solver | |
| env: | |
| COIN_DIST_URL: https://github.com/ampl/coin/releases/download/v20191215/coin-linux64.tar.gz | |
| LOCAL_BIN: ${{ runner.temp }}/.local/bin | |
| run: | | |
| set -eux | |
| mkdir -p "$LOCAL_BIN" | |
| echo "$LOCAL_BIN" >>"$GITHUB_PATH" | |
| wget -nv -O- "$COIN_DIST_URL" | tar -C "$RUNNER_TEMP" -xvz | |
| cp "${RUNNER_TEMP}/couenne" "${LOCAL_BIN}/couenne" | |
| chmod ugo+x "${LOCAL_BIN}/couenne" | |
| # | |
| # Setup Environment | |
| # | |
| # Configure AWS credentials | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4.0.2 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE }} | |
| aws-region: us-east-1 | |
| mask-aws-account-id: true | |
| # Set authentication with M2M token | |
| - name: Set authentication | |
| run: .github/scripts/get_m2m_token.sh | |
| env: | |
| IS_DEV: "false" | |
| M2M_SECRET_ARN: "${{ secrets.PROD_M2M_SECRET_ARN }}" | |
| # | |
| # Propagate CI information to python tests | |
| # | |
| - name: Get changed notebook files | |
| id: changed-files-ipynb | |
| uses: tj-actions/changed-files@v46.0.1 | |
| with: | |
| files: | | |
| **/*.ipynb | |
| - name: Get changed notebook test files | |
| id: changed-files-tests | |
| uses: tj-actions/changed-files@v46.0.1 | |
| with: | |
| files: | | |
| **/notebooks/**/test_*.py | |
| # Run Tests | |
| - name: Run Notebooks (quick tests) | |
| run: python -m pytest -c tests/config_quick_tests.ini --rootdir=. | |
| env: | |
| # to disable a warning in Jupyter notebooks | |
| JUPYTER_PLATFORM_DIRS: "1" | |
| # Passing which notebooks changed | |
| SHOULD_TEST_ALL_FILES: "true" # quick tests should run all files | |
| LIST_OF_IPYNB_CHANGED: "${{ steps.changed-files-ipynb.outputs.all_changed_files }}" | |
| LIST_OF_IPYNB_TESTS_CHANGED: "${{ steps.changed-files-tests.outputs.all_changed_files }}" | |
| # Altering test behavior | |
| LIMIT_TEST_LINKS_TO_FILES_ONLY: "true" | |
| - name: Run Notebooks (executing notebooks and testing content) | |
| run: python -m pytest -c tests/config_notebook_execute_tests.ini --rootdir=. | |
| env: | |
| # to disable a warning in Jupyter notebooks | |
| JUPYTER_PLATFORM_DIRS: "1" | |
| # Passing which notebooks changed | |
| SHOULD_TEST_ALL_FILES: "${{ env.SHOULD_TEST_ALL_FILES }}" | |
| LIST_OF_IPYNB_CHANGED: "${{ steps.changed-files-ipynb.outputs.all_changed_files }}" | |
| LIST_OF_IPYNB_TESTS_CHANGED: "${{ steps.changed-files-tests.outputs.all_changed_files }}" | |
| # Altering test behavior | |
| LIMIT_TEST_LINKS_TO_FILES_ONLY: "false" |