|
| 1 | +name: SonarCloud |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + types: [labeled, opened, synchronize, reopened, unlabeled] |
| 9 | +env: |
| 10 | + SCRIPT_FOLDER: ./.github/scripts |
| 11 | + RUN_TEST: source ../.github/scripts/run_test.sh |
| 12 | + |
| 13 | +jobs: |
| 14 | + sonarcloud: |
| 15 | + name: SonarCloud |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + python-version: ['3.10', '3.11'] |
| 20 | + |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Install poetry |
| 28 | + run: pip install poetry==1.8.4 |
| 29 | + |
| 30 | + - uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: ${{ matrix.python-version }} |
| 33 | + cache: 'poetry' |
| 34 | + |
| 35 | + - name: Set up AWS credentials |
| 36 | + env: |
| 37 | + AWS_ACCESS_KEY_ID: "FOOBARKEY" |
| 38 | + AWS_SECRET_ACCESS_KEY: "FOOBARSECRET" |
| 39 | + run: | |
| 40 | + aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID |
| 41 | + aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY |
| 42 | + |
| 43 | + - name: Chmod .github directory |
| 44 | + run: | |
| 45 | + chmod +x $SCRIPT_FOLDER/*.sh |
| 46 | + |
| 47 | + - name: Set Poetry to use in-project venvs |
| 48 | + run: poetry config virtualenvs.in-project true |
| 49 | + |
| 50 | + - name: Cache Poetry virtualenv (filenameprocessor) |
| 51 | + if: matrix.python-version == '3.10' |
| 52 | + uses: actions/cache@v4 |
| 53 | + with: |
| 54 | + path: ./filenameprocessor/.venv |
| 55 | + key: ${{ runner.os }}-venv-fp-py3.10-${{ hashFiles('filenameprocessor/poetry.lock') }} |
| 56 | + restore-keys: | |
| 57 | + ${{ runner.os }}-venv-fp-py3.10- |
| 58 | + |
| 59 | + - name: Cache Poetry virtualenv (recordprocessor) |
| 60 | + if: matrix.python-version == '3.10' |
| 61 | + uses: actions/cache@v4 |
| 62 | + with: |
| 63 | + path: ./recordprocessor/.venv |
| 64 | + key: ${{ runner.os }}-venv-rp-py3.10-${{ hashFiles('recordprocessor/poetry.lock') }} |
| 65 | + restore-keys: | |
| 66 | + ${{ runner.os }}-venv-rp-py3.10- |
| 67 | + |
| 68 | + - name: Cache Poetry virtualenv (recordforwarder) |
| 69 | + if: matrix.python-version == '3.11' |
| 70 | + uses: actions/cache@v4 |
| 71 | + with: |
| 72 | + path: ./backend/.venv |
| 73 | + key: ${{ runner.os }}-venv-be-py3.11-${{ hashFiles('backend/poetry.lock') }} |
| 74 | + restore-keys: | |
| 75 | + ${{ runner.os }}-venv-be-py3.11- |
| 76 | + |
| 77 | + - name: Cache Poetry virtualenv (ack_backend) |
| 78 | + if: matrix.python-version == '3.10' |
| 79 | + uses: actions/cache@v4 |
| 80 | + with: |
| 81 | + path: ./ack_backend/.venv |
| 82 | + key: ${{ runner.os }}-venv-ack-py3.10-${{ hashFiles('ack_backend/poetry.lock') }} |
| 83 | + restore-keys: | |
| 84 | + ${{ runner.os }}-venv-ack-py3.10- |
| 85 | + |
| 86 | + - name: Cache Poetry virtualenv (delta_backend) |
| 87 | + if: matrix.python-version == '3.11' |
| 88 | + uses: actions/cache@v4 |
| 89 | + with: |
| 90 | + path: ./delta_backend/.venv |
| 91 | + key: ${{ runner.os }}-venv-delta-py3.11-${{ hashFiles('delta_backend/poetry.lock') }} |
| 92 | + restore-keys: | |
| 93 | + ${{ runner.os }}-venv-delta-py3.11- |
| 94 | + |
| 95 | + - name: Run unittest with filenameprocessor-coverage (S) |
| 96 | + if: matrix.python-version == '3.10' |
| 97 | + working-directory: filenameprocessor |
| 98 | + id: filenameprocessor |
| 99 | + continue-on-error: true |
| 100 | + run: $RUN_TEST 3.10 filenameprocessor filenameprocessor-coverage.xml |
| 101 | + |
| 102 | + - name: Run unittest with recordprocessor-coverage (s) |
| 103 | + if: matrix.python-version == '3.10' |
| 104 | + working-directory: recordprocessor |
| 105 | + id: recordprocessor |
| 106 | + continue-on-error: true |
| 107 | + run: $RUN_TEST 3.10 recordprocessor recordprocessor-coverage.xml |
| 108 | + |
| 109 | + - name: Run unittest with recordforwarder-coverage |
| 110 | + if: matrix.python-version == '3.11' |
| 111 | + working-directory: backend |
| 112 | + id: recordforwarder |
| 113 | + continue-on-error: true |
| 114 | + run: | |
| 115 | + poetry config virtualenvs.in-project true |
| 116 | + $RUN_TEST 3.11 recordforwarder recordforwarder-coverage.xml |
| 117 | + |
| 118 | + - name: Run unittest with coverage-ack-lambda |
| 119 | + if: matrix.python-version == '3.10' |
| 120 | + working-directory: ack_backend |
| 121 | + id: acklambda |
| 122 | + continue-on-error: true |
| 123 | + run: $RUN_TEST 3.10 ack-lambda ack-lambda.xml |
| 124 | + |
| 125 | + - name: Run unittest with coverage-delta |
| 126 | + if: matrix.python-version == '3.11' |
| 127 | + working-directory: delta_backend |
| 128 | + id: delta |
| 129 | + env: |
| 130 | + PYTHONPATH: delta_backend/src:delta_backend/tests |
| 131 | + continue-on-error: true |
| 132 | + run: | |
| 133 | + poetry config virtualenvs.in-project true |
| 134 | + $RUN_TEST 3.11 delta_backend delta.xml |
| 135 | + |
| 136 | + - name: Run Test Failure Summary |
| 137 | + id: check_failure |
| 138 | + run: | |
| 139 | + if [ -s failed_tests.txt ]; then |
| 140 | + echo "The following tests failed:" |
| 141 | + cat failed_tests.txt |
| 142 | + |
| 143 | + while IFS= read -r line; do |
| 144 | + echo "##[error]Test Failures: $line" |
| 145 | + done < failed_tests.txt |
| 146 | + |
| 147 | + exit 1 |
| 148 | + else |
| 149 | + echo "All tests passed." |
| 150 | + fi |
| 151 | + |
| 152 | + - name: SonarCloud Scan |
| 153 | + uses: SonarSource/sonarqube-scan-action@master |
| 154 | + env: |
| 155 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any |
| 156 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
0 commit comments