|
| 1 | +name: Java CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + deploy: |
| 9 | + description: 'Deploy to Maven Central' |
| 10 | + type: boolean |
| 11 | + default: false |
| 12 | + luceeVersions: |
| 13 | + description: 'JSON array of Lucee versions to test' |
| 14 | + required: false |
| 15 | + default: '[{"version":"","query":"7.0/stable/light"},{"version":"","query":"7.1/snapshot/light"}]' |
| 16 | + |
| 17 | +jobs: |
| 18 | + setup: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + version: ${{ steps.extract-version.outputs.VERSION }} |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set up JDK 17 |
| 27 | + uses: actions/setup-java@v4 |
| 28 | + with: |
| 29 | + distribution: 'temurin' |
| 30 | + java-version: '17' |
| 31 | + |
| 32 | + - name: Cache Maven packages |
| 33 | + uses: actions/cache@v4 |
| 34 | + with: |
| 35 | + path: ~/.m2 |
| 36 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 37 | + restore-keys: | |
| 38 | + ${{ runner.os }}-maven- |
| 39 | +
|
| 40 | + - name: Extract version number |
| 41 | + id: extract-version |
| 42 | + run: | |
| 43 | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 44 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 45 | +
|
| 46 | + - name: Cache Lucee files |
| 47 | + uses: actions/cache@v4 |
| 48 | + with: |
| 49 | + path: ~/work/_actions/lucee/script-runner/main/lucee-download-cache |
| 50 | + key: lucee-downloads |
| 51 | + |
| 52 | + build-and-test: |
| 53 | + runs-on: ubuntu-latest |
| 54 | + needs: setup |
| 55 | + strategy: |
| 56 | + fail-fast: false |
| 57 | + matrix: |
| 58 | + lucee: ${{ fromJSON(inputs.luceeVersions || vars.LUCEE_TEST_VERSIONS_PLUS || '[{"version":"","query":"7.0/stable/light"},{"version":"","query":"7.1/snapshot/light"}]') }} |
| 59 | + services: |
| 60 | + samba: |
| 61 | + image: dperson/samba |
| 62 | + ports: |
| 63 | + - 139:139 |
| 64 | + - 445:445 |
| 65 | + env: |
| 66 | + USER: "smbuser;smbpass" |
| 67 | + SHARE: "public;/share;yes;no;no;all" |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Set up JDK 17 |
| 72 | + uses: actions/setup-java@v4 |
| 73 | + with: |
| 74 | + java-version: '17' |
| 75 | + distribution: 'temurin' |
| 76 | + |
| 77 | + - name: Build and Install with Maven |
| 78 | + run: | |
| 79 | + echo "------- Maven Install -------"; |
| 80 | + mvn -B -e -f pom.xml clean install |
| 81 | +
|
| 82 | + - name: Upload Artifact |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: smb-lex-${{ matrix.lucee.query }} |
| 86 | + path: target/*.lex |
| 87 | + |
| 88 | + - name: Wait for Samba to be ready |
| 89 | + run: | |
| 90 | + echo "Waiting for Samba to start..." |
| 91 | + for i in {1..30}; do |
| 92 | + if nc -z localhost 445 2>/dev/null; then |
| 93 | + echo "Samba port 445 is open!" |
| 94 | + sleep 5 |
| 95 | + break |
| 96 | + fi |
| 97 | + echo "Attempt $i: Samba not ready yet, waiting..." |
| 98 | + sleep 2 |
| 99 | + done |
| 100 | +
|
| 101 | + - name: Fix Samba share permissions |
| 102 | + run: | |
| 103 | + docker ps |
| 104 | + CONTAINER_ID=$(docker ps -q --filter "ancestor=dperson/samba") |
| 105 | + echo "Samba container: $CONTAINER_ID" |
| 106 | + docker exec $CONTAINER_ID sh -c 'chown 1000:1000 /share && chmod 777 /share' |
| 107 | + echo "Permissions fixed" |
| 108 | +
|
| 109 | + - name: Checkout Lucee |
| 110 | + uses: actions/checkout@v4 |
| 111 | + with: |
| 112 | + repository: lucee/lucee |
| 113 | + path: lucee |
| 114 | + |
| 115 | + - name: Run Lucee Test Suite |
| 116 | + uses: lucee/script-runner@main |
| 117 | + with: |
| 118 | + webroot: ${{ github.workspace }}/lucee/test |
| 119 | + execute: /bootstrap-tests.cfm |
| 120 | + luceeVersion: ${{ matrix.lucee.version }} |
| 121 | + luceeVersionQuery: ${{ matrix.lucee.query }} |
| 122 | + extensionDir: ${{ github.workspace }}/target |
| 123 | + env: |
| 124 | + testLabels: smb |
| 125 | + testAdditional: ${{ github.workspace }}/tests |
| 126 | + |
| 127 | + deploy: |
| 128 | + runs-on: ubuntu-latest |
| 129 | + needs: [setup, build-and-test] |
| 130 | + if: github.event_name == 'workflow_dispatch' && inputs.deploy && needs.build-and-test.result == 'success' |
| 131 | + steps: |
| 132 | + - name: Checkout repository |
| 133 | + uses: actions/checkout@v4 |
| 134 | + |
| 135 | + - name: Set up JDK 17 |
| 136 | + uses: actions/setup-java@v4 |
| 137 | + with: |
| 138 | + distribution: 'temurin' |
| 139 | + java-version: '17' |
| 140 | + |
| 141 | + - name: Cache Maven packages |
| 142 | + uses: actions/cache@v4 |
| 143 | + with: |
| 144 | + path: ~/.m2 |
| 145 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 146 | + restore-keys: | |
| 147 | + ${{ runner.os }}-maven- |
| 148 | +
|
| 149 | + - name: Import GPG key |
| 150 | + run: | |
| 151 | + echo "$GPG_PRIVATE_KEY" | base64 --decode | gpg --batch --import |
| 152 | + env: |
| 153 | + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 154 | + |
| 155 | + - name: Build and Deploy with Maven |
| 156 | + env: |
| 157 | + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} |
| 158 | + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} |
| 159 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 160 | + run: | |
| 161 | + if [[ "${{ needs.setup.outputs.version }}" == *-SNAPSHOT ]]; then |
| 162 | + echo "------- Maven Deploy snapshot on ${{ github.event_name }} -------"; |
| 163 | + mvn -B -e -f pom.xml clean deploy --settings maven-settings.xml |
| 164 | + else |
| 165 | + echo "------- Maven Deploy release on ${{ github.event_name }} -------"; |
| 166 | + mvn -B -e -f pom.xml clean deploy -DperformRelease=true --settings maven-settings.xml |
| 167 | + fi |
0 commit comments