|
| 1 | +name: CI ResponsibleAI-Text pytest |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + paths: |
| 9 | + - "responsibleai_text/**" |
| 10 | + - ".github/workflows/CI-responsibleai-text-pytest.yml" |
| 11 | + |
| 12 | +jobs: |
| 13 | + ci-python: |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + packageDirectory: ["responsibleai_text"] |
| 17 | + operatingSystem: [ubuntu-latest, macos-latest, windows-latest] |
| 18 | + pythonVersion: ["3.7", "3.8", "3.9", "3.10"] |
| 19 | + # TODO: re-add macos-latest once build timeout issues are resolved |
| 20 | + exclude: |
| 21 | + - packageDirectory: "responsibleai_text" |
| 22 | + operatingSystem: macos-latest |
| 23 | + pythonVersion: "3.7" |
| 24 | + - packageDirectory: "responsibleai_text" |
| 25 | + operatingSystem: macos-latest |
| 26 | + pythonVersion: "3.8" |
| 27 | + - packageDirectory: "responsibleai_text" |
| 28 | + operatingSystem: macos-latest |
| 29 | + pythonVersion: "3.9" |
| 30 | + - packageDirectory: "responsibleai_text" |
| 31 | + operatingSystem: macos-latest |
| 32 | + pythonVersion: "3.10" |
| 33 | + runs-on: ${{ matrix.operatingSystem }} |
| 34 | + |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v3 |
| 37 | + |
| 38 | + - uses: conda-incubator/setup-miniconda@v2 |
| 39 | + with: |
| 40 | + auto-update-conda: true |
| 41 | + python-version: ${{ matrix.pythonVersion }} |
| 42 | + |
| 43 | + - if: ${{ matrix.operatingSystem != 'macos-latest' }} |
| 44 | + name: Install pytorch on non-MacOS |
| 45 | + shell: bash -l {0} |
| 46 | + run: | |
| 47 | + conda install --yes --quiet pytorch torchvision captum cpuonly -c pytorch |
| 48 | +
|
| 49 | + - if: ${{ matrix.operatingSystem == 'macos-latest' }} |
| 50 | + name: Install Anaconda packages on MacOS, which should not include cpuonly according to official docs |
| 51 | + shell: bash -l {0} |
| 52 | + run: | |
| 53 | + conda install --yes --quiet pytorch torchvision captum -c pytorch |
| 54 | +
|
| 55 | + - name: Setup tools |
| 56 | + shell: bash -l {0} |
| 57 | + run: | |
| 58 | + python -m pip install --upgrade pip |
| 59 | + pip install --upgrade setuptools |
| 60 | + pip install --upgrade "pip-tools<=6.13.0" |
| 61 | +
|
| 62 | + - name: Install dependencies |
| 63 | + shell: bash -l {0} |
| 64 | + run: | |
| 65 | + pip install -r requirements-dev.txt |
| 66 | + pip install . |
| 67 | + working-directory: ${{ matrix.packageDirectory }} |
| 68 | + |
| 69 | + - name: Setup spacy |
| 70 | + shell: bash -l {0} |
| 71 | + run: | |
| 72 | + python -m spacy download en_core_web_sm |
| 73 | +
|
| 74 | + - name: Install package |
| 75 | + shell: bash -l {0} |
| 76 | + run: | |
| 77 | + pip install -v -e . |
| 78 | + working-directory: ${{ matrix.packageDirectory }} |
| 79 | + |
| 80 | + - name: Run tests |
| 81 | + shell: bash -l {0} |
| 82 | + run: | |
| 83 | + pytest -s -v --durations=10 --doctest-modules --junitxml=junit/test-results.xml --cov=${{ matrix.packageDirectory }} --cov-report=xml --cov-report=html |
| 84 | + working-directory: ${{ matrix.packageDirectory }} |
| 85 | + |
| 86 | + - name: Upload code coverage results |
| 87 | + uses: actions/upload-artifact@v3 |
| 88 | + with: |
| 89 | + name: ${{ matrix.packageDirectory }}-code-coverage-results |
| 90 | + path: ${{ matrix.packageDirectory }}/htmlcov |
| 91 | + # Use always() to always run this step to publish test results when there are test failures |
| 92 | + if: ${{ always() }} |
| 93 | + |
| 94 | + - if: ${{ (matrix.operatingSystem == 'windows-latest') && (matrix.pythonVersion == '3.8') }} |
| 95 | + name: Upload to codecov |
| 96 | + id: codecovupload1 |
| 97 | + uses: codecov/codecov-action@v3 |
| 98 | + with: |
| 99 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 100 | + directory: ${{ matrix.packageDirectory }} |
| 101 | + env_vars: OS,PYTHON |
| 102 | + fail_ci_if_error: false |
| 103 | + files: ./${{ matrix.packageDirectory }}/coverage.xml |
| 104 | + flags: unittests |
| 105 | + name: codecov-umbrella |
| 106 | + verbose: true |
| 107 | + |
| 108 | + - if: ${{ (steps.codecovupload1.outcome == 'failure') && (matrix.pythonVersion == '3.8') && (matrix.operatingSystem == 'windows-latest') }} |
| 109 | + name: Retry upload to codecov |
| 110 | + id: codecovupload2 |
| 111 | + uses: codecov/codecov-action@v3 |
| 112 | + with: |
| 113 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 114 | + directory: ${{ matrix.packageDirectory }} |
| 115 | + env_vars: OS,PYTHON |
| 116 | + fail_ci_if_error: false |
| 117 | + files: ./${{ matrix.packageDirectory }}/coverage.xml |
| 118 | + flags: unittests |
| 119 | + name: codecov-umbrella |
| 120 | + verbose: true |
| 121 | + |
| 122 | + - name: Set codecov status |
| 123 | + if: ${{ (matrix.pythonVersion == '3.8') && (matrix.operatingSystem == 'windows-latest') }} |
| 124 | + shell: bash |
| 125 | + run: | |
| 126 | + if ${{ (steps.codecovupload1.outcome == 'success') || (steps.codecovupload2.outcome == 'success') }} ; then |
| 127 | + echo fine |
| 128 | + else |
| 129 | + exit 1 |
| 130 | + fi |
0 commit comments