|
| 1 | +name: cbDebugger CI |
| 2 | + |
| 3 | +# Only on Development we build snapshots |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - development |
| 8 | + - master |
| 9 | + |
| 10 | +env: |
| 11 | + MODULE_ID: cbdebugger |
| 12 | + |
| 13 | +jobs: |
| 14 | + ############################################# |
| 15 | + # Tests First baby! We fail, no build :( |
| 16 | + ############################################# |
| 17 | + tests: |
| 18 | + name: Tests |
| 19 | + runs-on: ubuntu-20.04 |
| 20 | + env: |
| 21 | + DB_USER: root |
| 22 | + DB_PASSWORD: root |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + cfengine: [ "lucee@5", "adobe@2016", "adobe@2018", "adobe@2021" ] |
| 27 | + steps: |
| 28 | + - name: Checkout Repository |
| 29 | + uses: actions/checkout@v2 |
| 30 | + |
| 31 | + - name: Setup Java |
| 32 | + uses: actions/setup-java@v2 |
| 33 | + with: |
| 34 | + distribution: "adopt" |
| 35 | + java-version: "11" |
| 36 | + |
| 37 | + - name: Setup Database and Fixtures |
| 38 | + run: | |
| 39 | + sudo /etc/init.d/mysql start |
| 40 | + # Create Database |
| 41 | + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -e 'CREATE DATABASE coolblog;' |
| 42 | + # Import Database |
| 43 | + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < test-harness/tests/resources/coolblog.sql |
| 44 | +
|
| 45 | + - name: Setup Environment For Testing Process |
| 46 | + working-directory: ./test-harness |
| 47 | + run: | |
| 48 | + # Setup .env |
| 49 | + touch .env |
| 50 | + # ENV |
| 51 | + printf "DB_HOST=localhost\n" >> .env |
| 52 | + printf "DB_USER=${{ env.DB_USER }}\n" >> .env |
| 53 | + printf "DB_PASSWORD=${{ env.DB_PASSWORD }}\n" >> .env |
| 54 | + printf "DB_CLASS=com.mysql.cj.jdbc.Driver\n" >> .env |
| 55 | + printf "DB_BUNDLEVERSION=8.0.19\n" >> .env |
| 56 | + printf "DB_BUNDLENAME=com.mysql.cj\n" >> .env |
| 57 | +
|
| 58 | + - name: Cache CommandBox Dependencies |
| 59 | + uses: actions/cache@v1 |
| 60 | + if: ${{ true }} |
| 61 | + with: |
| 62 | + path: ~/.CommandBox/artifacts |
| 63 | + key: ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }} |
| 64 | + restore-keys: | |
| 65 | + ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }} |
| 66 | +
|
| 67 | + - name: Setup CommandBox |
| 68 | + |
| 69 | + |
| 70 | + - name: Install Test Harness Dependencies |
| 71 | + working-directory: ./test-harness |
| 72 | + run: | |
| 73 | + box install |
| 74 | +
|
| 75 | + - name: Start ${{ matrix.cfengine }} Server |
| 76 | + working-directory: ./test-harness |
| 77 | + run: | |
| 78 | + box server start serverConfigFile="server-${{ matrix.cfengine }}.json" --noSaveSettings --debug |
| 79 | + # Install Adobe 2021 cfpm modules |
| 80 | + if [[ "${{ matrix.cfengine }}" == "adobe@2021" ]] ; then |
| 81 | + box run-script install:2021 |
| 82 | + fi |
| 83 | + curl http://127.0.0.1:60299 |
| 84 | +
|
| 85 | + - name: Run Tests |
| 86 | + working-directory: ./test-harness |
| 87 | + run: | |
| 88 | + mkdir tests/results |
| 89 | + box package set testbox.runner="http://localhost:60299/tests/runner.cfm" |
| 90 | + box testbox run --verbose outputFile=tests/results/test-results outputFormats=json,antjunit |
| 91 | +
|
| 92 | + - name: Publish Test Results |
| 93 | + uses: EnricoMi/publish-unit-test-result-action@v1 |
| 94 | + if: always() |
| 95 | + with: |
| 96 | + files: test-harness/tests/results/**/*.xml |
| 97 | + check_name: "${{ matrix.cfengine }} Test Results" |
| 98 | + |
| 99 | + - name: Upload Test Results Artifacts |
| 100 | + if: always() |
| 101 | + uses: actions/upload-artifact@v2 |
| 102 | + with: |
| 103 | + name: test-results-${{ matrix.cfengine }} |
| 104 | + path: | |
| 105 | + test-harness/tests/results/**/* |
| 106 | +
|
| 107 | + - name: Slack Notification |
| 108 | + if: failure() |
| 109 | + uses: rtCamp/action-slack-notify@v2 |
| 110 | + env: |
| 111 | + SLACK_CHANNEL: coding |
| 112 | + SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' |
| 113 | + SLACK_ICON_EMOJI: ":bell:" |
| 114 | + SLACK_MESSAGE: '${{ env.MODULE_ID }} tests failed :cry:' |
| 115 | + SLACK_TITLE: ${{ env.MODULE_ID }} Tests For ${{ matrix.cfengine }} failed |
| 116 | + SLACK_USERNAME: CI |
| 117 | + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 118 | + |
| 119 | + - name: Failure Debugging Info |
| 120 | + if: ${{ failure() }} |
| 121 | + working-directory: ./test-harness |
| 122 | + run: | |
| 123 | + box server log serverConfigFile="server-${{ matrix.cfengine }}.json" |
| 124 | +
|
| 125 | + - name: Upload Debugging Info To Artifacts |
| 126 | + if: ${{ failure() }} |
| 127 | + uses: actions/upload-artifact@v2 |
| 128 | + with: |
| 129 | + name: Failure Debugging Info - ${{ matrix.cfengine }} |
| 130 | + path: | |
| 131 | + test-harness/.engine/**/logs/* |
| 132 | + test-harness/.engine/**/WEB-INF/cfusion/logs/* |
| 133 | +
|
| 134 | + ############################################# |
| 135 | + # Build Module |
| 136 | + ############################################# |
| 137 | + build: |
| 138 | + name: Build & Publish |
| 139 | + needs: tests |
| 140 | + runs-on: ubuntu-20.04 |
| 141 | + steps: |
| 142 | + - name: Checkout Repository |
| 143 | + uses: actions/checkout@v2 |
| 144 | + with: |
| 145 | + fetch-depth: 0 |
| 146 | + |
| 147 | + - name: Setup Java |
| 148 | + uses: actions/setup-java@v2 |
| 149 | + with: |
| 150 | + distribution: "adopt" |
| 151 | + java-version: "11" |
| 152 | + |
| 153 | + - name: Setup nodejs |
| 154 | + uses: actions/setup-node@v2 |
| 155 | + with: |
| 156 | + node-version: 12.x |
| 157 | + |
| 158 | + - name: Cache CommandBox Dependencies |
| 159 | + uses: actions/cache@v1 |
| 160 | + if: ${{ true }} |
| 161 | + with: |
| 162 | + path: ~/.CommandBox/artifacts |
| 163 | + key: ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }} |
| 164 | + restore-keys: | |
| 165 | + ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }}-${{ hashFiles( 'test-harness/box.json' ) }} |
| 166 | +
|
| 167 | + - name: Setup CommandBox |
| 168 | + |
| 169 | + with: |
| 170 | + forgeboxAPIKey: ${{ secrets.FORGEBOX_TOKEN }} |
| 171 | + |
| 172 | + - name: Setup Environment Variables For Build Process |
| 173 | + id: current_version |
| 174 | + run: | |
| 175 | + echo "VERSION=`cat box.json | jq '.version' -r`" >> $GITHUB_ENV |
| 176 | + |
| 177 | + # master or snapshot |
| 178 | + echo "Github Ref is $GITHUB_REF" |
| 179 | + echo "BRANCH=master" >> $GITHUB_ENV |
| 180 | + if [ $GITHUB_REF == 'refs/heads/development' ] |
| 181 | + then |
| 182 | + echo "BRANCH=development" >> $GITHUB_ENV |
| 183 | + fi |
| 184 | +
|
| 185 | + - name: Build ${{ env.MODULE_ID }} |
| 186 | + run: | |
| 187 | + npm i npm@latest -g |
| 188 | + npm install |
| 189 | + npm run prod |
| 190 | + rm -Rf node_modules |
| 191 | + box install commandbox-docbox |
| 192 | + box task run taskfile=build/Build target=run :version=${{ env.VERSION }} :projectName=${{ env.MODULE_ID }} :buildID=${{ github.run_number }} :branch=${{ env.BRANCH }} |
| 193 | +
|
| 194 | + - name: Upload Build Artifacts |
| 195 | + if: success() |
| 196 | + uses: actions/upload-artifact@v2 |
| 197 | + with: |
| 198 | + name: ${{ env.MODULE_ID }} |
| 199 | + path: | |
| 200 | + .artifacts/**/* |
| 201 | +
|
| 202 | + - name: Upload Binaries to S3 |
| 203 | + uses: jakejarvis/s3-sync-action@master |
| 204 | + with: |
| 205 | + args: --acl public-read |
| 206 | + env: |
| 207 | + AWS_S3_BUCKET: "downloads.ortussolutions.com" |
| 208 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} |
| 209 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} |
| 210 | + SOURCE_DIR: ".artifacts/${{ env.MODULE_ID }}" |
| 211 | + DEST_DIR: "ortussolutions/coldbox-modules/${{ env.MODULE_ID }}" |
| 212 | + |
| 213 | + - name: Upload API Docs to S3 |
| 214 | + uses: jakejarvis/s3-sync-action@master |
| 215 | + with: |
| 216 | + args: --acl public-read |
| 217 | + env: |
| 218 | + AWS_S3_BUCKET: "apidocs.ortussolutions.com" |
| 219 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} |
| 220 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} |
| 221 | + SOURCE_DIR: ".tmp/apidocs" |
| 222 | + DEST_DIR: "coldbox-modules/${{ env.MODULE_ID }}/${{ env.VERSION }}" |
| 223 | + |
| 224 | + - name: Publish To ForgeBox |
| 225 | + run: | |
| 226 | + cd .tmp/${{ env.MODULE_ID }} |
| 227 | + cat box.json |
| 228 | + box forgebox publish |
| 229 | +
|
| 230 | + - name: Inform Slack |
| 231 | + if: ${{ always() }} |
| 232 | + uses: rtCamp/action-slack-notify@v2 |
| 233 | + env: |
| 234 | + SLACK_CHANNEL: coding |
| 235 | + SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' |
| 236 | + SLACK_ICON_EMOJI: ":bell:" |
| 237 | + SLACK_MESSAGE: '${{ env.MODULE_ID }} Built with ${{ job.status }}!' |
| 238 | + SLACK_TITLE: "${{ env.MODULE_ID }} Build" |
| 239 | + SLACK_USERNAME: CI |
| 240 | + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} |
0 commit comments