|
| 1 | +name: "Test Library CI (qmods)" |
| 2 | + |
| 3 | +on: [pull_request] |
| 4 | + |
| 5 | +defaults: |
| 6 | + run: |
| 7 | + shell: bash |
| 8 | + |
| 9 | +jobs: |
| 10 | + detect-qmod-changes: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | + outputs: |
| 17 | + has_any_qmod_file_changed: ${{ steps.changed-files.outputs.any_changed }} |
| 18 | + changed_qmod_files: ${{ steps.changed-files.outputs.all_changed_files }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Check for changed QMOD files |
| 25 | + id: changed-files |
| 26 | + uses: tj-actions/changed-files@v46 |
| 27 | + with: |
| 28 | + files: | |
| 29 | + **/*.qmod |
| 30 | +
|
| 31 | + test: |
| 32 | + needs: detect-qmod-changes |
| 33 | + if: needs.detect-qmod-changes.outputs.has_any_qmod_file_changed == 'true' |
| 34 | + |
| 35 | + runs-on: ubuntu-latest |
| 36 | + |
| 37 | + permissions: |
| 38 | + id-token: write |
| 39 | + contents: read |
| 40 | + |
| 41 | + steps: |
| 42 | + # |
| 43 | + # Setup Python |
| 44 | + # |
| 45 | + - name: Set up Python |
| 46 | + uses: actions/setup-python@v5 |
| 47 | + with: |
| 48 | + python-version: "3.11" |
| 49 | + |
| 50 | + - name: Install dependencies |
| 51 | + run: | |
| 52 | + set -e |
| 53 | + python -m pip install -U pip |
| 54 | + python -m pip install -U -r requirements.txt |
| 55 | + python -m pip install -U -r requirements_tests.txt |
| 56 | +
|
| 57 | + # |
| 58 | + # Setup qmod_parser |
| 59 | + # |
| 60 | + # Configure AWS credentials |
| 61 | + - name: Configure AWS Credentials |
| 62 | + uses: aws-actions/configure-aws-credentials@v4.0.2 |
| 63 | + with: |
| 64 | + role-to-assume: ${{ secrets.AWS_ROLE }} |
| 65 | + aws-region: us-east-1 |
| 66 | + mask-aws-account-id: true |
| 67 | + |
| 68 | + - name: Download and install Qmod parser |
| 69 | + env: |
| 70 | + WHL_FILE_NAME: qmod_parser-0.0.0-cp311-cp311-linux_x86_64.whl |
| 71 | + S3_BUCKET_SOURCE: s3://public-library-resources |
| 72 | + run: | |
| 73 | + set -eux |
| 74 | + classiq_version=$(pip show classiq | awk '/Version:/ {print $2}') |
| 75 | + mkdir qmod_parser |
| 76 | + aws s3 cp "$S3_BUCKET_SOURCE/qmod_parser/$classiq_version/$WHL_FILE_NAME" "qmod_parser/$WHL_FILE_NAME" |
| 77 | + python -m pip install "qmod_parser/$WHL_FILE_NAME" |
| 78 | +
|
| 79 | + # |
| 80 | + # Setup Environment |
| 81 | + # |
| 82 | + # Set authentication with M2M token |
| 83 | + - name: Set authentication |
| 84 | + run: .github/scripts/get_m2m_token.sh |
| 85 | + env: |
| 86 | + IS_DEV: "false" |
| 87 | + M2M_SECRET_ARN: "${{ secrets.PROD_M2M_SECRET_ARN }}" |
| 88 | + |
| 89 | + # Run Tests |
| 90 | + - name: Run qmod tests |
| 91 | + run: python -m pytest tests/qmods/test_qmods.py |
| 92 | + env: |
| 93 | + # Passing which notebooks changed |
| 94 | + SHOULD_TEST_ALL_FILES: "true" # quick tests should run all files |
| 95 | + LIST_OF_QMOD_CHANGED: "${{ needs.detect-qmod-changes.outputs.changed_qmod_files }}" |
0 commit comments