Skip to content

Commit c43db80

Browse files
Merge pull request #83 from cnescatlab/feature/github-action
Add github actions
2 parents e645a2a + 16a4bba commit c43db80

File tree

4 files changed

+127
-37
lines changed

4 files changed

+127
-37
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ What types of changes does your code introduce to this plugin?
2525
- [ ] I have read the [CONTRIBUTING](https://github.com/lequal/sonar-icode-cnes-plugin/blob/master/CONTRIBUTING.md) doc
2626
- [ ] I agree with the [CODE OF CONDUCT](https://github.com/lequal/sonar-icode-cnes-plugin/blob/master/CONTRIBUTING.md)
2727
- [ ] Lint and unit tests pass locally with my changes
28-
- [ ] SonarCloud and Travis CI tests pass with my changes
28+
- [ ] SonarCloud and GitHub CI tests pass with my changes
2929
- [ ] I have added tests that prove my fix is effective or that my feature works
3030
- [ ] I have added necessary documentation (if appropriate)
3131
- [ ] Any dependent changes have been merged and published in downstream modules
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Description
2+
# ===========
3+
# This workflow is triggered each time a milestone is closed
4+
# It builds the jar, generates release notes, pushes a new tag
5+
# and makes a draft release with these elements.
6+
---
7+
name: Draft Release
8+
9+
on:
10+
milestone:
11+
types: [closed]
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out repository code
18+
uses: actions/checkout@v2
19+
- name: Setup java
20+
uses: actions/setup-java@v2
21+
with:
22+
distribution: 'adopt'
23+
java-version: '11'
24+
- name: Cache Maven packages
25+
uses: actions/cache@v2
26+
with:
27+
path: ~/.m2
28+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
29+
restore-keys: ${{ runner.os }}-m2
30+
- name: Build with Maven
31+
run: mvn -B clean package
32+
- name: Create Release Notes
33+
uses: docker://decathlon/release-notes-generator-action:2.0.1
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
OUTPUT_FOLDER: temp_release_notes
37+
- name: Set tag and project values
38+
run: |
39+
echo "tag=$(cat pom.xml | grep "<version>.*</version>" | head -1 |awk -F'[><]' '{print $3}')" >> $GITHUB_ENV
40+
echo "project=$(echo ${{ github.repository }} | awk -F '/' '{print $2}')" >> $GITHUB_ENV
41+
- name: Create a tag for the release
42+
run: |
43+
git config --global user.name "GitHub Actions"
44+
git config --global user.email [email protected]
45+
git tag -a ${{ env.tag }} -m "Release ${{ env.tag }}"
46+
git push origin ${{ env.tag }}
47+
- name: Create GitHub Release
48+
uses: ncipollo/release-action@v1
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
artifacts: "target/${{ env.project }}-${{ env.tag }}.jar"
53+
tag: ${{ env.tag }}
54+
name: ${{ env.project }} ${{ env.tag }}
55+
bodyFile: "temp_release_notes/release_file.md"
56+
draft: true
57+
token: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Description
2+
# ===========
3+
# This workflow is triggered each time
4+
# commits are pushed to GitHub or a pull request is opened.
5+
# It launches three jobs in parallel : a build with java 8,
6+
# a build with java 11 and a SonarCloud analysis.
7+
---
8+
name: Java CI
9+
10+
on: [push, pull_request]
11+
12+
jobs:
13+
14+
build:
15+
runs-on: ubuntu-latest
16+
name: Java 11 CI
17+
steps:
18+
- name: Check out repository code
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
- name: Setup java
23+
uses: actions/setup-java@v2
24+
with:
25+
distribution: 'adopt'
26+
java-version: 11
27+
- name: Cache Maven packages
28+
uses: actions/cache@v2
29+
with:
30+
path: ~/.m2
31+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32+
restore-keys: ${{ runner.os }}-m2
33+
- name: Build with Maven
34+
run: mvn -B clean test package
35+
36+
code-analysis:
37+
runs-on: ubuntu-latest
38+
name: SonarCloud Code Analysis
39+
# It's not possible to launch an analysis on external pull requests
40+
if: ${{ github.repository_owner == 'cnescatlab' }}
41+
steps:
42+
- name: Check out repository code
43+
uses: actions/checkout@v2
44+
with:
45+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
46+
- name: Setup java
47+
uses: actions/setup-java@v2
48+
with:
49+
distribution: 'adopt'
50+
java-version: '11'
51+
- name: Cache Maven packages
52+
uses: actions/cache@v2
53+
with:
54+
path: ~/.m2
55+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
56+
restore-keys: ${{ runner.os }}-m2
57+
- name: Cache SonarCloud packages
58+
uses: actions/cache@v2
59+
with:
60+
path: ~/.sonar/cache
61+
key: ${{ runner.os }}-sonar
62+
restore-keys: ${{ runner.os }}-sonar
63+
- name: Build and analyze
64+
env:
65+
# Needed to get some information about the pull request, if any
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
# SonarCloud access token should be generated from https://sonarcloud.io/account/security/
68+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
69+
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

.travis.yml

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

0 commit comments

Comments
 (0)