diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6229191..e5cfc6c 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -25,7 +25,7 @@ What types of changes does your code introduce to this plugin? - [ ] I have read the [CONTRIBUTING](https://github.com/lequal/sonar-icode-cnes-plugin/blob/master/CONTRIBUTING.md) doc - [ ] I agree with the [CODE OF CONDUCT](https://github.com/lequal/sonar-icode-cnes-plugin/blob/master/CONTRIBUTING.md) - [ ] Lint and unit tests pass locally with my changes -- [ ] SonarCloud and Travis CI tests pass with my changes +- [ ] SonarCloud and GitHub CI tests pass with my changes - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added necessary documentation (if appropriate) - [ ] Any dependent changes have been merged and published in downstream modules diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml new file mode 100644 index 0000000..4cfe39e --- /dev/null +++ b/.github/workflows/draft-release.yml @@ -0,0 +1,57 @@ +# Description +# =========== +# This workflow is triggered each time a milestone is closed +# It builds the jar, generates release notes, pushes a new tag +# and makes a draft release with these elements. +--- +name: Draft Release + +on: + milestone: + types: [closed] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v2 + - name: Setup java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build with Maven + run: mvn -B clean package + - name: Create Release Notes + uses: docker://decathlon/release-notes-generator-action:2.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OUTPUT_FOLDER: temp_release_notes + - name: Set tag and project values + run: | + echo "tag=$(cat pom.xml | grep ".*" | head -1 |awk -F'[><]' '{print $3}')" >> $GITHUB_ENV + echo "project=$(echo ${{ github.repository }} | awk -F '/' '{print $2}')" >> $GITHUB_ENV + - name: Create a tag for the release + run: | + git config --global user.name "GitHub Actions" + git config --global user.email catlab@cnes.fr + git tag -a ${{ env.tag }} -m "Release ${{ env.tag }}" + git push origin ${{ env.tag }} + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + artifacts: "target/${{ env.project }}-${{ env.tag }}.jar" + tag: ${{ env.tag }} + name: ${{ env.project }} ${{ env.tag }} + bodyFile: "temp_release_notes/release_file.md" + draft: true + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/java-continuous-integration.yml b/.github/workflows/java-continuous-integration.yml new file mode 100644 index 0000000..e5d9235 --- /dev/null +++ b/.github/workflows/java-continuous-integration.yml @@ -0,0 +1,69 @@ +# Description +# =========== +# This workflow is triggered each time +# commits are pushed to GitHub or a pull request is opened. +# It launches three jobs in parallel : a build with java 8, +# a build with java 11 and a SonarCloud analysis. +--- +name: Java CI + +on: [push, pull_request] + +jobs: + + build: + runs-on: ubuntu-latest + name: Java 11 CI + steps: + - name: Check out repository code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: 11 + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build with Maven + run: mvn -B clean test package + + code-analysis: + runs-on: ubuntu-latest + name: SonarCloud Code Analysis + # It's not possible to launch an analysis on external pull requests + if: ${{ github.repository_owner == 'cnescatlab' }} + steps: + - name: Check out repository code + uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Setup java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Cache SonarCloud packages + uses: actions/cache@v2 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Build and analyze + env: + # Needed to get some information about the pull request, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # SonarCloud access token should be generated from https://sonarcloud.io/account/security/ + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.organization=lequal -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index dbfdc24..0000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -language: java -sudo: false -install: true - -os: linux -dist: xenial - -addons: - sonarcloud: - organization: "lequal" - -jdk: openjdk11 - -script: -- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar - -cache: - directories: - - '$HOME/.m2/repository' - - '$HOME/.sonar/cache' - -notifications: - email: false - -deploy: - provider: releases - token: "$GITHUB_TOKEN" - file_glob: true - file: "target/sonar-icode-cnes-plugin-*.jar" - skip_cleanup: true - name: "Sonar i-Code CNES plugin version $TRAVIS_TAG" - draft: true - on: - branch: master - tags: true - jdk: openjdk11