Skip to content

Commit

Permalink
GA: Fikser publish + legger itl sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
espenwaaga committed Dec 2, 2021
1 parent 84511a9 commit ef9c4f5
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/.m2/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_USERNAME}</username>
<password>${env.GITHUB_PASSWORD}</password>
<username>x-access-token</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
32 changes: 18 additions & 14 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
name: Bygg pull request

on: [pull_request]
on:
pull_request:
branches:
- master
paths-ignore:
- '**.md'
- '**.MD'
- '.gitignore'
- 'LICENCE'
- 'CODEOWNERS'
- '.github/workflows/build.yml'
- '.github/workflows/release.yml'
- '.github/release-drafter.yml'
- '.github/dependabot.yml'

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Sjekk ut kode
uses: actions/checkout@v2

- name: Cache maven repository
uses: actions/cache@v2.1.6
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

- name: Set up JDK 16
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '16'

cache: 'maven'
- name: Build
shell: bash
run: |
echo "Building $(echo $GITHUB_SHA | cut -c1-7)"
mvn package -e --batch-mode --settings ./.github/.m2/settings.xml --file pom.xml -Dchangelist= -Dsha1=-$(git log -1 --pretty='%ad' --date=format:'%Y%m%d%H%M%S')-$(echo $GITHUB_SHA | cut -c1-7)
mvn jacoco:prepare-agent package jacoco:report sonar:sonar -e --batch-mode --settings .github/.m2/settings.xml -Dchangelist= -Dsha1=-$(git log -1 --pretty='%ad' --date=format:'%Y%m%d%H%M%S')-$(echo $GITHUB_SHA | cut -c1-7) -Dsonar.login=${SONAR_TOKEN}
env:
GITHUB_USERNAME: x-access-token
GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
22 changes: 12 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ on:
push:
branches:
- master # Push events on master branch
paths-ignore:
- '**.md'
- '**.MD'
- '.gitignore'
- 'LICENCE'
- 'CODEOWNERS'
- '.github/workflows/build-pr.yml'
- '.github/workflows/release.yml'
- '.github/release-drafter.yml'
- '.github/dependabot.yml'

jobs:
release-notes:
Expand All @@ -21,18 +31,12 @@ jobs:
- name: Sjekk ut kode
uses: actions/checkout@v2
- run: git fetch --prune --unshallow

- name: Cache maven repository
uses: actions/cache@v2.1.6
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}

- name: Set up JDK 16
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '16'
cache: 'maven'

- name: Hent tag
run: |
Expand All @@ -46,10 +50,8 @@ jobs:
shell: bash
run: |
mvn versions:set -DnewVersion=${MVN_VERSION}
mvn --quiet jacoco:prepare-agent deploy -e --batch-mode --settings ./.github/.m2/settings.xml -Dsonar.login=${SONAR_TOKEN} -Djacoco.destFile=$(pwd)/target/jacoco.exec
mvn jacoco:prepare-agent deploy jacoco:report sonar:sonar -e --batch-mode --settings .github/.m2/settings.xml -Dsonar.login=${SONAR_TOKEN}
mvn versions:revert
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_USERNAME: x-access-token
GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
11 changes: 2 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ jobs:
with:
distribution: 'adopt'
java-version: '16'
cache: 'maven'

- name: Setup build cache
uses: actions/cache@v2.1.6
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Publish artifact
env:
NEW_VERSION: ${{ github.event.release.tag_name }}
GITHUB_USERNAME: x-access-token
GITHUB_PASSWORD: ${{ secrets.RELEASE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn -B --settings .github/.m2/settings.xml versions:set -DnewVersion=${NEW_VERSION}
mvn -B --settings .github/.m2/settings.xml clean deploy
26 changes: 23 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@
</developers>

<properties>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>navit</sonar.organization>
<sonar.projectKey>navikt_fp-uttak</sonar.projectKey>
<java.version>16</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<sonar.moduleKey>${project.artifactId}</sonar.moduleKey>
<sonar.projectKey>navikt_fp-uttak</sonar.projectKey>
<sonar.organization>navit</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<fpsak.nare.version>2.1.5</fpsak.nare.version>
<jupiter.version>5.8.1</jupiter.version>
<assertj.version>3.21.0</assertj.version>
Expand Down Expand Up @@ -158,6 +159,25 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
Expand Down

0 comments on commit ef9c4f5

Please sign in to comment.