Skip to content

Commit 6a68165

Browse files
committed
Refactor GitHub Actions Workflows (#131)
Merge pull request #131 from adangel:refactor-gh-actions
2 parents e085e78 + 1186937 commit 6a68165

File tree

13 files changed

+247
-246
lines changed

13 files changed

+247
-246
lines changed

.ci/build.sh

Lines changed: 0 additions & 100 deletions
This file was deleted.

.ci/inc/fetch_ci_scripts.bash

Lines changed: 0 additions & 19 deletions
This file was deleted.

.ci/manual-integration-tests.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,75 @@
1-
name: build
1+
name: Build
22

33
on:
4+
pull_request:
5+
merge_group:
46
push:
57
branches:
6-
- main
7-
tags:
88
- '**'
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:
1012
schedule:
1113
# build it monthly: At 04:30 on day-of-month 1.
1214
- 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'
1427

1528
jobs:
16-
build:
17-
timeout-minutes: 120
29+
compile:
1830
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
2135
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

.github/workflows/manual-integration-tests.yml

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,46 @@ on:
66
- cron: '30 8 1 * *'
77
workflow_dispatch:
88

9+
permissions:
10+
contents: read # to fetch code (actions/checkout)
11+
12+
env:
13+
LANG: 'en_US.UTF-8'
14+
915
jobs:
1016
build:
1117
timeout-minutes: 120
1218
runs-on: ubuntu-latest
1319
continue-on-error: false
1420
steps:
15-
- uses: actions/checkout@v4
16-
- uses: actions/cache@v4
17-
with:
18-
path: |
19-
~/.m2/repository
20-
~/.cache
21-
~/.gradle
22-
vendor/bundle
23-
target/repositories
24-
key: v3-${{ runner.os }}-${{ hashFiles('pmdtester.gemspec') }}
25-
restore-keys: |
26-
v3-${{ runner.os }}-
27-
- name: Set up Ruby 3.3
28-
uses: ruby/setup-ruby@v1
29-
with:
30-
ruby-version: 3.3
31-
- name: Setup Environment
32-
shell: bash
33-
run: |
34-
echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
35-
echo "MAVEN_OPTS=-Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3" >> $GITHUB_ENV
36-
echo "PMD_CI_SCRIPTS_URL=https://raw.githubusercontent.com/pmd/build-tools/main/scripts" >> $GITHUB_ENV
37-
- name: Check Environment
38-
shell: bash
39-
run: |
40-
f=check-environment.sh; \
41-
mkdir -p .ci && \
42-
( [ -e .ci/$f ] || curl -sSL "${PMD_CI_SCRIPTS_URL}/$f" > ".ci/$f" ) && \
43-
chmod 755 .ci/$f && \
44-
.ci/$f
45-
- name: Build
46-
run: .ci/manual-integration-tests.sh
47-
shell: bash
48-
env:
49-
PMD_CI_SECRET_PASSPHRASE: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }}
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-java@v4
23+
with:
24+
distribution: 'temurin'
25+
java-version: '11'
26+
- name: Prepare HOME/openjdk11
27+
run: ln -sfn "${JAVA_HOME_11_X64}" "${HOME}/openjdk11"
28+
- uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.m2/repository
32+
~/.cache
33+
~/.gradle
34+
vendor/bundle
35+
target/repositories
36+
key: v4-${{ runner.os }}-${{ hashFiles('pmdtester.gemspec') }}
37+
restore-keys: |
38+
v4-${{ runner.os }}-
39+
- name: Set up Ruby 3.3
40+
uses: ruby/setup-ruby@v1
41+
with:
42+
ruby-version: 3.3
43+
- name: Install dependencies (bundler)
44+
run: |
45+
# bundler should already be installed
46+
bundle --version
47+
bundle config set --local path vendor/bundle
48+
bundle install
49+
- name: Run Manual Integration Tests
50+
run: |
51+
bundle exec ruby -I test test/manual_integration_tests.rb

0 commit comments

Comments
 (0)