|
| 1 | +name: 'testing ${{ env.TESTED_PARSER }}-parser on ${{ env.TESTED_BRANCH }} branch' |
| 2 | + |
| 3 | +# This workflow is triggered on pushes, pull requests, or can be run manually. |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [ main, master ] # Adjust to your default branch |
| 7 | + pull_request: |
| 8 | + branches: [ main, master ] # Adjust to your default branch |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +# Environment variables available to all jobs in the workflow |
| 12 | +env: |
| 13 | + TESTED_BRANCH: master |
| 14 | + TESTED_PARSER: jsoniq |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Build |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Set up JDK 11 and Maven |
| 22 | + uses: actions/setup-java@v4 |
| 23 | + with: |
| 24 | + java-version: '11' |
| 25 | + distribution: 'temurin' |
| 26 | + maven-version: '3.9.9' |
| 27 | + |
| 28 | + - name: Clone and Build Rumble Repository |
| 29 | + run: | |
| 30 | + echo "cloning ${{ env.TESTED_BRANCH }}" |
| 31 | + git clone --single-branch --branch "${{ env.TESTED_BRANCH }}" "https://github.com/gfourny/rumble.git" |
| 32 | + cd rumble |
| 33 | + mvn clean compile assembly:single -quiet |
| 34 | + cd .. |
| 35 | + |
| 36 | + - name: Upload build artifact |
| 37 | + uses: actions/upload-artifact@v4 |
| 38 | + with: |
| 39 | + name: rumble-build |
| 40 | + path: rumble/target |
| 41 | + |
| 42 | + test: |
| 43 | + name: Test - ${{ matrix.test_name }} |
| 44 | + needs: build |
| 45 | + runs-on: ubuntu-latest |
| 46 | + # Use a matrix to run all test jobs in parallel |
| 47 | + strategy: |
| 48 | + fail-fast: false # Allows all tests to finish even if one fails |
| 49 | + matrix: |
| 50 | + test_name: [ 'app', 'array', 'fn1', 'fn2', 'map', 'math', 'misc', 'op', 'prod1', 'prod2', 'ser', 'xs' ] |
| 51 | + |
| 52 | + # The job will be marked with a warning but won't fail the workflow. |
| 53 | + continue-on-error: true |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Set up JDK 11 and Maven |
| 57 | + uses: actions/setup-java@v4 |
| 58 | + with: |
| 59 | + java-version: '11' |
| 60 | + distribution: 'temurin' |
| 61 | + maven-version: '3.9.9' |
| 62 | + |
| 63 | + - name: Download build artifact |
| 64 | + uses: actions/download-artifact@v4 |
| 65 | + with: |
| 66 | + name: rumble-build |
| 67 | + path: . # download to the root |
| 68 | + |
| 69 | + - name: Run Maven Tests |
| 70 | + id: run-tests |
| 71 | + run: | |
| 72 | + # Capitalize the first letter of the test_name to form the class name |
| 73 | + TEST_CLASS=$(echo ${{ matrix.test_name }} | awk '{print toupper(substr($0,1,1))substr($0,2)}')Test |
| 74 | +
|
| 75 | + if [ "${{ env.TESTED_PARSER }}" = "jsoniq" ]; then |
| 76 | + mvn -Dtest=${TEST_CLASS} test -quiet |
| 77 | + else |
| 78 | + mvn -Dtest=XQuery${TEST_CLASS} test -quiet |
| 79 | + fi |
| 80 | +
|
| 81 | + - name: Upload Surefire reports |
| 82 | + # Corresponds to `when: always` |
| 83 | + if: always() |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: surefire-report-${{ matrix.test_name }} |
| 87 | + path: target/surefire-reports/*.xml |
| 88 | + retention-days: 7 |
| 89 | + |
| 90 | + spotless-check: |
| 91 | + name: Spotless Check |
| 92 | + needs: build |
| 93 | + runs-on: ubuntu-latest |
| 94 | + steps: |
| 95 | + - name: Set up JDK 11 and Maven |
| 96 | + uses: actions/setup-java@v4 |
| 97 | + with: |
| 98 | + java-version: '11' |
| 99 | + distribution: 'temurin' |
| 100 | + maven-version: '3.9.9' |
| 101 | + |
| 102 | + - name: Download build artifact |
| 103 | + uses: actions/download-artifact@v4 |
| 104 | + with: |
| 105 | + name: rumble-build |
| 106 | + path: . |
| 107 | + |
| 108 | + - name: Run Spotless Check |
| 109 | + run: mvn spotless:check |
| 110 | + |
| 111 | + publish-test-results: |
| 112 | + name: Publish Test Results |
| 113 | + # This job runs after all jobs in the `test` matrix have completed. |
| 114 | + needs: test |
| 115 | + runs-on: ubuntu-latest |
| 116 | + # This job should always run to report on which tests passed or failed. |
| 117 | + if: always() |
| 118 | + steps: |
| 119 | + - name: Download all surefire reports |
| 120 | + uses: actions/download-artifact@v4 |
| 121 | + with: |
| 122 | + # Download all artifacts that match this pattern |
| 123 | + pattern: surefire-report-* |
| 124 | + path: all-surefire-reports |
| 125 | + merge-multiple: true # merge all downloaded artifacts into one directory |
| 126 | + |
| 127 | + - name: Publish Unit Test Results |
| 128 | + uses: EnricoMi/publish-unit-test-results-action@v2 |
| 129 | + with: |
| 130 | + files: all-surefire-reports/**/*.xml |
| 131 | + |
| 132 | + collect: |
| 133 | + name: Collect Artifacts |
| 134 | + needs: [test, spotless-check] |
| 135 | + runs-on: ubuntu-latest |
| 136 | + # Corresponds to `when: always` |
| 137 | + if: always() |
| 138 | + steps: |
| 139 | + # Checkout the repository to get access to analytics scripts etc. |
| 140 | + - uses: actions/checkout@v4 |
| 141 | + |
| 142 | + - name: Set up JDK 11 and Maven |
| 143 | + uses: actions/setup-java@v4 |
| 144 | + with: |
| 145 | + java-version: '11' |
| 146 | + distribution: 'temurin' |
| 147 | + maven-version: '3.9.9' |
| 148 | + |
| 149 | + - name: Download build artifact |
| 150 | + uses: actions/download-artifact@v4 |
| 151 | + with: |
| 152 | + name: rumble-build |
| 153 | + path: . |
| 154 | + |
| 155 | + - name: Download all surefire reports |
| 156 | + uses: actions/download-artifact@v4 |
| 157 | + with: |
| 158 | + pattern: surefire-report-* |
| 159 | + path: all-surefire-reports |
| 160 | + merge-multiple: true |
| 161 | + |
| 162 | + - name: Collect and process artifacts |
| 163 | + run: | |
| 164 | + mkdir -p collected-artifacts/surefire-reports |
| 165 | + # Copy all downloaded reports into the target directory for processing |
| 166 | + cp all-surefire-reports/*.xml target/surefire-reports/ |
| 167 | + cp -r target/surefire-reports collected-artifacts/ |
| 168 | + |
| 169 | + # Run the collection/analytics Java code |
| 170 | + mvn compile |
| 171 | + mvn exec:java |
| 172 | +
|
| 173 | + - name: Upload collected data |
| 174 | + uses: actions/upload-artifact@v4 |
| 175 | + with: |
| 176 | + name: collected-data |
| 177 | + path: | |
| 178 | + collected-artifacts |
| 179 | + analytics-results |
| 180 | +
|
| 181 | + plot: |
| 182 | + name: Analytics and Plotting |
| 183 | + needs: collect |
| 184 | + runs-on: ubuntu-latest |
| 185 | + # Corresponds to `when: always` |
| 186 | + if: always() |
| 187 | + steps: |
| 188 | + # Checkout the repository to get the analytics scripts |
| 189 | + - uses: actions/checkout@v4 |
| 190 | + |
| 191 | + - name: Set up Python 3.12 |
| 192 | + uses: actions/setup-python@v5 |
| 193 | + with: |
| 194 | + python-version: '3.12' |
| 195 | + |
| 196 | + - name: Download collected data |
| 197 | + uses: actions/download-artifact@v4 |
| 198 | + with: |
| 199 | + name: collected-data |
| 200 | + path: . |
| 201 | + |
| 202 | + - name: Install dependencies and run plotting script |
| 203 | + run: | |
| 204 | + pip install -r analytics/requirements.txt |
| 205 | + python analytics/plot.py |
| 206 | + echo "TO SEE THE PLOTS, CHECK THE ARTIFACTS OF THIS WORKFLOW RUN" |
| 207 | + |
| 208 | + - name: Upload plots |
| 209 | + uses: actions/upload-artifact@v4 |
| 210 | + with: |
| 211 | + name: plots-and-results |
| 212 | + path: | |
| 213 | + plots |
| 214 | + analytics-results |
0 commit comments