diff --git a/.circleci/config.yml b/.circleci/config.yml index 3886f38a..09ea4095 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -95,39 +95,37 @@ jobs: - *clean_sbt_cache - *save_sbt_cache - publish_lib: + publish: <<: *default_sbt_job steps: - attach_workspace: at: ~/ - *restore_sbt_cache - run: - name: Publish the library + name: Publish the library and binary command: | sbt ";clean;retrieveGPGKeys" - sbt ";+publishSigned;sonatypeReleaseAll" - - *clean_sbt_cache - - *save_sbt_cache + sbt ";publishSigned;sonatypeRelease" - publish_binary: - <<: *default_sbt_job - steps: - - attach_workspace: - at: ~/ - - *restore_sbt_cache - - run: - name: Publish the library - command: | ./scripts/publish-native.sh -n codacy-coverage-reporter -m com.codacy.CodacyCoverageReporter -t docker $(cat .version) mkdir -p /tmp/binary cp ~/workdir/codacy-coverage-reporter-linux-$(cat .version) /tmp/binary/codacy-coverage-reporter-linux + cp ~/workdir/target/codacy-coverage-reporter-assembly-$(cat .version).jar /tmp/binary/codacy-coverage-reporter-assembly.jar curl -fL https://getcli.jfrog.io | sh ./jfrog bt config --interactive=false --user codacy-ci --key $BINTRAY_API_KEY - ./jfrog bt upload --user codacy-ci --key $BINTRAY_API_KEY --publish /tmp/binary/ codacy/Binaries/codacy-coverage-reporter/$(cat .version) codacy-coverage-reporter-linux + ./jfrog bt upload --user codacy-ci --key $BINTRAY_API_KEY --publish /tmp/binary/ codacy/Binaries/codacy-coverage-reporter/$(cat .version) + GHR_FLAGS="" + if [ "${CIRCLE_BRANCH}" != "master" ]; then + GHR_FLAGS+="-prerelease" + fi + + mkdir -p /tmp/ghr-publish + cp ~/workdir/codacy-coverage-reporter-linux-$(cat .version) /tmp/ghr-publish + cp ~/workdir/target/codacy-coverage-reporter-assembly-$(cat .version).jar /tmp/ghr-publish/codacy-coverage-reporter-$(cat .version)-assembly.jar go get github.com/tcnksm/ghr - ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete $(cat .version) ~/workdir/codacy-coverage-reporter-linux-$(cat .version) + ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${GHR_FLAGS} -delete $(cat .version) /tmp/ghr-publish - *clean_sbt_cache - *save_sbt_cache @@ -150,20 +148,12 @@ workflows: context: CodacyAWS requires: - populate_cache - - publish_lib: - filters: - branches: - only: - - master - context: CodacyAWS - requires: - - compile_and_test - - checkfmt - - publish_binary: + - publish: filters: branches: only: - master + - native-binary context: CodacyAWS requires: - compile_and_test diff --git a/README.md b/README.md index 5c135f05..10430c5b 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ export CODACY_PROJECT_TOKEN=%Project_Token% ### Linux amd64 +Download the latest binary and use it to post the coverage to Codacy + +#### Bintray + ```bash LATEST_VERSION=$(curl -Lqs https://api.bintray.com/packages/codacy/Binaries/codacy-coverage-reporter/versions/_latest | jq -r .name) curl -o codacy-coverage-reporter https://dl.bintray.com/codacy/Binaries/${LATEST_VERSION}/:codacy-coverage-reporter-linux @@ -32,14 +36,33 @@ chmod +x codacy-coverage-reporter ./codacy-coverage-reporter report -l Java -r build/reports/jacoco/test/jacocoTestReport.xml ``` +#### GitHub + +```sh +curl $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets | map({name, browser_download_url} | select(.name | contains("codacy-coverage-reporter-linux"))) | .[0].browser_download_url') -o codacy-coverage-reporter +chmod +x codacy-coverage-reporter +./codacy-coverage-reporter report -l Java -r build/reports/jacoco/test/jacocoTestReport.xml +``` + ### Others -1. Download the latest jar from https://github.com/codacy/codacy-coverage-reporter/releases/latest +* Linux x86, MacOS, Windows, ... -2. Run the command below (changing for the version you just downloaded) +Download the latest jar and use it to post the coverage to Codacy -```bash -$ java -jar codacy-coverage-reporter-assembly-.jar report -l Java -r jacoco.xml +#### Bintray + +```sh +LATEST_VERSION=$(curl -Lqs https://api.bintray.com/packages/codacy/Binaries/codacy-coverage-reporter/versions/_latest | jq -r .name) +curl -o codacy-coverage-reporter-assembly.jar https://dl.bintray.com/codacy/Binaries/${LATEST_VERSION}/:codacy-coverage-reporter-assembly.jar +java -jar codacy-coverage-reporter-assembly.jar report -l Java -r build/reports/jacoco/test/jacocoTestReport.xml +``` + +#### GitHub + +```sh +curl $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets | map({content_type, browser_download_url} | select(.content_type | contains("application/x-java-archive"))) | .[0].browser_download_url') -o codacy-coverage-reporter-assembly.jar +java -jar codacy-coverage-reporter-assembly.jar report -l Java -r jacoco.xml ``` ### CommitUUID Detection @@ -206,10 +229,10 @@ If you want to use codacy with Travis CI and report coverage generated from your ```yaml before_install: - sudo apt-get install jq - - wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets[0].browser_download_url') + - curl $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets | map({content_type, browser_download_url} | select(.content_type | contains("application/x-java-archive"))) | .[0].browser_download_url') -o codacy-coverage-reporter-assembly.jar after_success: - - java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r build/reports/jacoco/test/jacocoTestReport.xml + - java -jar ~/codacy-coverage-reporter-assembly.jar report -l Java -r build/reports/jacoco/test/jacocoTestReport.xml ``` Make sure you have set `CODACY_PROJECT_TOKEN` as an environment variable in your travis job! diff --git a/scripts/publish-native.sh b/scripts/publish-native.sh index aed3f383..b5050164 100755 --- a/scripts/publish-native.sh +++ b/scripts/publish-native.sh @@ -70,7 +70,7 @@ if [ -n "$1" ]; then fi function app_classpath() { - echo $(cat /dev/null | sbt ';clean;compile;export runtime:fullClasspath' | tail -n 1) + echo $(cat /dev/null | sbt ';compile;export runtime:fullClasspath' | tail -n 1) } function build_cmd() { @@ -115,7 +115,7 @@ case "$TARGET" in -v $HOME/.ivy2:$HOME/.ivy2 \ -v $HOME/.sbt:$HOME/.sbt \ -v $PWD:$PWD \ - oracle/graalvm-ce:1.0.0-rc13 \ + oracle/graalvm-ce:1.0.0-rc14 \ -c "${BUILD_CMD}" ;; *)