|
1 | | -name: build |
| 1 | +name: Build |
2 | 2 |
|
3 | 3 | on: |
| 4 | + pull_request: |
| 5 | + merge_group: |
4 | 6 | push: |
5 | 7 | branches: |
6 | | - - main |
7 | | - tags: |
8 | 8 | - '**' |
9 | | - pull_request: |
| 9 | + # don't run on dependabot branches. Dependabot will create pull requests, which will then be run instead |
| 10 | + - '!dependabot/**' |
| 11 | + workflow_dispatch: |
10 | 12 | schedule: |
11 | 13 | # build it monthly: At 04:30 on day-of-month 1. |
12 | 14 | - cron: '30 4 1 * *' |
13 | | - workflow_dispatch: |
| 15 | + |
| 16 | +# if another commit is added to the same branch or PR (same github.ref), |
| 17 | +# then cancel already running jobs and start a new build. |
| 18 | +concurrency: |
| 19 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read # to fetch code (actions/checkout) |
| 24 | + |
| 25 | +env: |
| 26 | + LANG: 'en_US.UTF-8' |
14 | 27 |
|
15 | 28 | jobs: |
16 | | - build: |
17 | | - timeout-minutes: 120 |
| 29 | + compile: |
18 | 30 | runs-on: ubuntu-latest |
19 | | - continue-on-error: false |
20 | | - if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} |
| 31 | + timeout-minutes: 120 |
| 32 | + defaults: |
| 33 | + run: |
| 34 | + shell: bash |
21 | 35 | steps: |
22 | | - - uses: actions/checkout@v4 |
23 | | - - uses: actions/cache@v4 |
24 | | - with: |
25 | | - path: | |
26 | | - ~/.m2/repository |
27 | | - ~/.cache |
28 | | - ~/.gradle |
29 | | - vendor/bundle |
30 | | - target/repositories |
31 | | - key: v3-${{ runner.os }}-${{ hashFiles('pmdtester.gemspec') }} |
32 | | - restore-keys: | |
33 | | - v3-${{ runner.os }}- |
34 | | - - name: Set up Ruby 3.3 |
35 | | - uses: ruby/setup-ruby@v1 |
36 | | - with: |
37 | | - ruby-version: 3.3 |
38 | | - - name: Setup Environment |
39 | | - shell: bash |
40 | | - run: | |
41 | | - echo "LANG=en_US.UTF-8" >> $GITHUB_ENV |
42 | | - echo "MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3" >> $GITHUB_ENV |
43 | | - echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/main/scripts" >> $GITHUB_ENV |
44 | | - - name: Check Environment |
45 | | - shell: bash |
46 | | - run: | |
47 | | - f=check-environment.sh; \ |
48 | | - mkdir -p .ci && \ |
49 | | - ( [ -e .ci/$f ] || curl -sSL "${PMD_CI_SCRIPTS_URL}/$f" > ".ci/$f" ) && \ |
50 | | - chmod 755 .ci/$f && \ |
51 | | - .ci/$f |
52 | | - - name: Build |
53 | | - run: .ci/build.sh |
54 | | - shell: bash |
55 | | - env: |
56 | | - PMD_CI_SECRET_PASSPHRASE: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }} |
57 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + - uses: actions/setup-java@v4 |
| 38 | + with: |
| 39 | + distribution: 'temurin' |
| 40 | + java-version: '11' |
| 41 | + - name: Prepare HOME/openjdk11 |
| 42 | + run: ln -sfn "${JAVA_HOME_11_X64}" "${HOME}/openjdk11" |
| 43 | + - uses: actions/cache@v4 |
| 44 | + with: |
| 45 | + path: | |
| 46 | + ~/.m2/repository |
| 47 | + ~/.cache |
| 48 | + ~/.gradle |
| 49 | + vendor/bundle |
| 50 | + target/repositories |
| 51 | + key: v4-${{ runner.os }}-${{ hashFiles('pmdtester.gemspec') }} |
| 52 | + restore-keys: | |
| 53 | + v4-${{ runner.os }}- |
| 54 | + - name: Set up Ruby 3.3 |
| 55 | + uses: ruby/setup-ruby@v1 |
| 56 | + with: |
| 57 | + ruby-version: 3.3 |
| 58 | + - name: Install dependencies (bundler) |
| 59 | + run: | |
| 60 | + # bundler should already be installed |
| 61 | + bundle --version |
| 62 | + bundle config set --local path vendor/bundle |
| 63 | + bundle install |
| 64 | + - name: Build with rake |
| 65 | + run: | |
| 66 | + bundle exec rake check_manifest |
| 67 | + bundle exec rake rubocop |
| 68 | + bundle exec rake clean test |
| 69 | + - name: Run Integration Tests |
| 70 | + run: | |
| 71 | + bundle exec rake clean integration-test |
| 72 | + - name: Build Package |
| 73 | + run: | |
| 74 | + bundle exec rake install_gem |
| 75 | + bundle exec pmdtester -h |
0 commit comments