Integrate danger for pull requests
This commit is contained in:
@ -9,10 +9,17 @@ for a ssh key, which is used to copy files to sourceforge.
|
||||
|
||||
## Environment variables
|
||||
|
||||
* `PMD_CI_SECRET_PASSPHRASE`
|
||||
* `CI_DEPLOY_PASSWORD`
|
||||
* `CI_SIGN_PASSPHRASE`
|
||||
* ...
|
||||
* PMD_CI_SECRET_PASSPHRASE
|
||||
* CI_DEPLOY_USER
|
||||
* CI_DEPLOY_PASSWORD
|
||||
* CI_SIGN_KEY
|
||||
* CI_SIGN_PASSPHRASE
|
||||
* PMD_SF_USER
|
||||
* PMD_SF_APIKEY
|
||||
* GITHUB_OAUTH_TOKEN
|
||||
* GITHUB_BASE_URL
|
||||
* DANGER_GITHUB_API_TOKEN
|
||||
* PMD_CI_CHUNK_TOKEN
|
||||
|
||||
## Encrypting
|
||||
|
||||
|
21
.ci/build-pr.sh
Executable file
21
.ci/build-pr.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source $(dirname $0)/inc/logger.inc
|
||||
source $(dirname $0)/inc/setup-secrets.inc
|
||||
source $(dirname $0)/inc/regression-tester.inc
|
||||
source ${HOME}/java.env
|
||||
|
||||
set -e
|
||||
#set -x
|
||||
|
||||
./mvnw -e -Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3 -V clean verify
|
||||
|
||||
# Danger is executed only on the linux runner
|
||||
case "$(uname)" in
|
||||
Linux*)
|
||||
log_info "Executing danger..."
|
||||
pmd_ci_setup_env
|
||||
regression_tester_setup_ci
|
||||
regression_tester_executeDanger
|
||||
;;
|
||||
esac
|
12
.ci/build.sh
12
.ci/build.sh
@ -31,7 +31,7 @@ function pmd_ci_build_main() {
|
||||
|
||||
pmd_ci_build_and_upload_doc
|
||||
|
||||
pmd_ci_build_setup_regression_tester
|
||||
regression_tester_setup_ci
|
||||
regression_tester_uploadBaseline
|
||||
|
||||
exit 0
|
||||
@ -95,15 +95,7 @@ function pmd_ci_build_run() {
|
||||
./mvnw deploy -Possrh,sign,generate-rule-docs $MVN_BUILD_FLAGS
|
||||
}
|
||||
|
||||
function pmd_ci_build_setup_regression_tester() {
|
||||
# install openjdk8 for pmd-regression-tests
|
||||
.ci/install-openjdk.sh 8
|
||||
rm -f .bundle/config
|
||||
bundle config set --local path vendor/bundle
|
||||
bundle config set --local with release_notes_preprocessing
|
||||
bundle install
|
||||
}
|
||||
|
||||
# Needed for doc generation and regression tester
|
||||
function pmd_ci_build_setup_bundler() {
|
||||
log_info "Installing bundler..."
|
||||
gem install bundler
|
||||
|
Binary file not shown.
@ -6,6 +6,23 @@
|
||||
# PMD_SF_USER
|
||||
# PMD_CI_BRANCH
|
||||
|
||||
function regression_tester_setup_ci() {
|
||||
# install openjdk8 for pmd-regression-tests
|
||||
.ci/install-openjdk.sh 8
|
||||
|
||||
if hash "bundler" 2>/dev/null; then
|
||||
log_debug "Bundler is already installed"
|
||||
else
|
||||
log_info "Installing bundler..."
|
||||
gem install bundler
|
||||
fi
|
||||
|
||||
rm -f .bundle/config
|
||||
bundle config set --local path vendor/bundle
|
||||
bundle config set --local with release_notes_preprocessing
|
||||
bundle install
|
||||
}
|
||||
|
||||
#
|
||||
# Generate a new baseline and upload it to sourceforge
|
||||
#
|
||||
@ -58,7 +75,6 @@ function regression_tester_uploadBaseline() {
|
||||
# In that case, just a error logging is provided.
|
||||
#
|
||||
function regression_tester_executeDanger() {
|
||||
change_ruby_version
|
||||
log_debug "$FUNCNAME"
|
||||
|
||||
local errexitstate="$(shopt -po errexit)"
|
||||
@ -73,6 +89,10 @@ function regression_tester_executeDanger() {
|
||||
set -e
|
||||
trap danger_failed ERR
|
||||
|
||||
PMD_CI_BRANCH=${PMD_CI_BRANCH##refs/heads/}
|
||||
export PMD_CI_BRANCH
|
||||
log_debug "Using modified branch name: ${PMD_CI_BRANCH}"
|
||||
|
||||
# Create a corresponding remote branch locally
|
||||
if ! git show-ref --verify --quiet refs/heads/${PMD_CI_BRANCH}; then
|
||||
git fetch --no-tags origin +refs/heads/${PMD_CI_BRANCH}:refs/remotes/origin/${PMD_CI_BRANCH}
|
||||
|
18
.github/workflows/pull-requests.yml
vendored
18
.github/workflows/pull-requests.yml
vendored
@ -21,15 +21,17 @@ jobs:
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-
|
||||
- name: Set up Ruby 2.7
|
||||
uses: actions/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.7
|
||||
- name: Install OpenJDK 11
|
||||
run: .ci/install-openjdk.sh 11
|
||||
shell: bash
|
||||
- name: Build with mvnw
|
||||
run: |
|
||||
source ${HOME}/java.env
|
||||
./mvnw -e -Dmaven.wagon.httpconnectionManager.ttlSeconds=180 -Dmaven.wagon.http.retryHandler.count=3 -V clean install
|
||||
shell: bash
|
||||
- name: Execute Danger
|
||||
if: ${{ runner.os == 'Linux' }}
|
||||
run: echo "TODO"
|
||||
- name: Build
|
||||
run: .ci/build-pr.sh
|
||||
shell: bash
|
||||
env:
|
||||
PMD_CI_SECRET_PASSPHRASE: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }}
|
||||
PMD_CI_BRANCH: ${{ github.ref }}
|
||||
PMD_CI_PULL_REQUEST_NUMBER: ${{ github.event.number }}
|
||||
|
17
Dangerfile
17
Dangerfile
@ -7,10 +7,10 @@ require 'logger'
|
||||
def run_pmdtester
|
||||
Dir.chdir('..') do
|
||||
argv = ['--local-git-repo', './pmd',
|
||||
'--list-of-project', './pmd/.travis/project-list.xml',
|
||||
'--base-branch', "#{ENV['TRAVIS_BRANCH']}",
|
||||
'--list-of-project', './pmd/.ci/files/project-list.xml',
|
||||
'--base-branch', "#{ENV['PMD_CI_BRANCH']}",
|
||||
'--patch-branch', 'HEAD',
|
||||
'--patch-config', './pmd/.travis/all-java.xml',
|
||||
'--patch-config', './pmd/.ci/files/all-java.xml',
|
||||
'--mode', 'online',
|
||||
'--auto-gen-config',
|
||||
# '--debug',
|
||||
@ -28,14 +28,14 @@ end
|
||||
|
||||
def upload_report
|
||||
Dir.chdir('target/reports') do
|
||||
tar_filename = "pr-#{ENV['TRAVIS_PULL_REQUEST']}-diff-report-#{Time.now.strftime("%Y-%m-%dT%H-%M-%SZ")}.tar"
|
||||
tar_filename = "pr-#{ENV['PMD_CI_PULL_REQUEST_NUMBER']}-diff-report-#{Time.now.strftime("%Y-%m-%dT%H-%M-%SZ")}.tar"
|
||||
unless Dir.exist?('diff/')
|
||||
message("No java rules are changed!", sticky: true)
|
||||
return
|
||||
end
|
||||
|
||||
`tar -cf #{tar_filename} diff/`
|
||||
report_url = `curl -u #{ENV['CHUNK_TOKEN']} -T #{tar_filename} https://chunk.io`
|
||||
report_url = `curl -u #{ENV['PMD_CI_CHUNK_TOKEN']} -T #{tar_filename} https://chunk.io`
|
||||
if $?.success?
|
||||
@logger.info "Successfully uploaded #{tar_filename} to chunk.io"
|
||||
|
||||
@ -53,11 +53,6 @@ def upload_report
|
||||
end
|
||||
|
||||
# Perform regression testing
|
||||
can_merge = github.pr_json['mergeable']
|
||||
if can_merge
|
||||
run_pmdtester
|
||||
else
|
||||
warn("This PR cannot be merged yet.", sticky: false)
|
||||
end
|
||||
run_pmdtester
|
||||
|
||||
# vim: syntax=ruby
|
||||
|
Reference in New Issue
Block a user