Skip to content

Commit

Permalink
LIBS-1053 - Update dependencies and MySQL docker image version (#19)
Browse files Browse the repository at this point in the history
* LIBS-1053 - Update dependencies and MySQL docker image version

* LIBS-1053 - further updates

Co-authored-by: fegbers <[email protected]>
  • Loading branch information
Henrik Adamski and fegbers authored Feb 10, 2022
1 parent b6d79e0 commit 4e0c350
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 29 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# This configuration is used for nightly builds
name: nightly

on:
schedule:
- cron: 0 0 * * 1
# Runs every Monday at 00:00
- cron: 0 0 * * MON

jobs:
nightly:
Expand All @@ -11,30 +13,45 @@ jobs:
runs-on: ubuntu-latest

steps:
# Setup java environment
- name: setup-java
uses: actions/setup-java@v1
with:
java-version: 11

# Checkout the git repository
- name: checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GPR_TOKEN }}
fetch-depth: ''

# Execute some necessary git commands to get more repository informations
- name: post-checkout
run: git fetch --prune --unshallow

# Setup/load GitHub Actions caching for external dependencies, in this case especially for Maven
- name: caching
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

# Execute Maven command for compile and compile of the tests
- name: compile
run: mvn clean compile test-compile

# Execute Unit tests
- name: unit-tests
run: mvn surefire:test

# Execute Integration tests, in this case we can skip the unit tests and load these with jacoco
- name: integration-tests
run: mvn -DskipUTs -Dgpg.skip=true jacoco:restore-instrumented-classes verify

# Execute sonar analysis and publish results to the sonarqube server
- name: sonar-analyse
env:
SONAR_HOST: ${{ secrets.OS_SONAR_HOST_URL }}
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# This configuration is used for the deployment and publish to GitHub Packages
name: release

on:
push:
branches:
# Runs only on push to the master branch
- master

jobs:
Expand All @@ -15,6 +17,7 @@ jobs:
runs-on: ubuntu-latest

steps:
# Setup java environment
- name: setup-java
uses: actions/setup-java@v1
with:
Expand All @@ -23,31 +26,45 @@ jobs:
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD

# Checkout the git repository
- name: setup-github-release
run: sed -i -e 's/<\/servers>/<server><id>github<\/id><username>x-access-token<\/username><password>${GITHUB_TOKEN}<\/password><\/server><\/servers>/g' /home/runner/.m2/settings.xml

# Setup GPG for Maven Central deployment
- name: setup-gpg
env:
GPG_PRIVATE_KEY: ${{ secrets.OS_GPG_PRIVATE_KEY }}
run: cat <(echo -e "${GPG_PRIVATE_KEY}") | gpg --batch --import

# Checkout the git repository
- name: checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GPR_TOKEN }}
fetch-depth: ''

# Execute some necessary git commands to get more repository informations
- name: post-checkout
run: git fetch --prune --unshallow

# Setup GitHub Actions caching for external dependencies, in this case especially for Maven
- name: caching
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

# Execute Maven command for the deployment and publish to Maven Central
- name: deploy
env:
OSSRH_USERNAME: ${{ secrets.OS_OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OS_OSSRH_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.OS_GPG_PASSPHRASE }}
run: mvn deploy -Dmaven.wagon.http.pool=false -Dgpg.executable=gpg -Dgpg.passphrase=${GPG_PASSPHRASE}

# Execute sonar analysis and publish results to the sonarcloud server
- name: sonar-analyse
env:
SONAR_HOST: ${{ secrets.OS_SONAR_HOST_URL }}
Expand All @@ -60,3 +77,35 @@ jobs:
-Dsonar.organization=${SONAR_ORGANIZATION} \
-Dsonar.projectKey=${GITHUB_REPOSITORY//\//_} \
-Dsonar.java.binaries=./target/classes
# Get the current project version from POM
- name: get-project-version
id: get_project_version
uses: avides/actions-project-version-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
file-to-check: pom.xml
only-return-version: true

# Get last commit message for GitHub Release tag
- name: setup-github-release
id: setup_github_release
env:
PROJECT_VERSION: ${{ steps.get_project_version.outputs.version }}
run: |
echo ::set-output name=gitcommitmessage::$(git log --no-merges -1 --oneline)
if [[ "$PROJECT_VERSION" == *"SNAPSHOT"* || "$PROJECT_VERSION" == *"RC"* ]]; then
echo ::set-output name=isprerelease::true
fi
# Create and publish GitHub Release tag
- name: github-release
uses: actions/create-release@v1
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GPR_TOKEN }}
with:
tag_name: ${{ steps.get_project_version.outputs.version }}
release_name: ${{ steps.get_project_version.outputs.version }}
body: ${{ steps.setup_github_release.outputs.gitcommitmessage }}
prerelease: ${{ steps.setup_github_release.outputs.isprerelease }}
62 changes: 62 additions & 0 deletions .github/workflows/review.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# This configuration is used for the pull request review
name: review

on:
pull_request:
# Runs only on pull request creation and on every new commit to the created pull request
types: [opened, synchronize]

jobs:
Expand All @@ -11,37 +13,95 @@ jobs:
runs-on: ubuntu-latest

steps:
# Cancels previous run for this branch that have a different commit id (SHA)
- name: cancel-previous-run
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

# Setup java environment
- name: setup-java
uses: actions/setup-java@v1
with:
java-version: 11

# Checkout the git repository
- name: checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GPR_TOKEN }}
fetch-depth: ''

# Execute some necessary git commands to get more repository informations
- name: post-checkout
run: git fetch --prune --unshallow

# Update GitHub Action configuration if necessary
- name: action-configuration-autoupdate
uses: avides/actions-action-configuration-autoupdate@v1
with:
token: ${{ secrets.GPR_TOKEN }}
actions-configuration-files: os-java-library/nightly.yml,os-java-library/release.yml,os-java-library/review.yml
source-repository: ${{ secrets.ACTIONS_CONFIG_AUTOUPDATE_REPO }}

# Push updated GitHub Actions configuration if necessary
- uses: stefanzweifel/git-auto-commit-action@v4
with:
file_pattern: .github/workflows/*.yml
commit_user_name: ${{ secrets.ACTIONS_CONFIG_AUTOUPDATE_USER }}
commit_user_email: ${{ secrets.ACTIONS_CONFIG_AUTOUPDATE_EMAIL }}
commit_author: ${{ secrets.ACTIONS_CONFIG_AUTOUPDATE_AUTHOR }}
commit_message: Update GitHub Action configuration

# Verify project version is updated
- name: project-version-check
uses: avides/actions-project-version-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
file-to-check: pom.xml
additional-files-to-check: README.md

# Check if documentation reminder comment is already given
- name: find-documentation-reminder-comment
uses: peter-evans/find-comment@v1
id: find_documentation_reminder_comment
with:
issue-number: ${{ github.event.number }}
body-includes: "Confluence/GitHub documentation added or updated?"

# Add documentation reminder comment if not given
- name: documentation-reminder-comment
uses: jungwinter/comment@v1
id: create
if: ${{ steps.find_documentation_reminder_comment.outputs.comment-id == 0 }}
with:
type: create
body: 'Confluence/GitHub documentation added or updated?'
issue_number: ${{ github.event.number }}
token: ${{ secrets.GITHUB_TOKEN }}

# Setup/load GitHub Actions caching for external dependencies, in this case especially for Maven
- name: caching
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

# Execute Maven command for compile and compile of the tests
- name: compile
run: mvn clean compile test-compile

# Execute Unit tests
- name: unit-tests
run: mvn surefire:test

# Execute Integration tests, in this case we can skip the unit tests and load these with jacoco
- name: integration-tests
run: mvn -DskipUTs -Dgpg.skip=true jacoco:restore-instrumented-classes verify

# Execute sonar analysis for current branch
- name: sonar-analyse
env:
SONAR_HOST: ${{ secrets.OS_SONAR_HOST_URL }}
Expand All @@ -56,8 +116,10 @@ jobs:
-Dsonar.projectKey=${GITHUB_REPOSITORY//\//_} \
-Dsonar.pullrequest.key=${{ github.event.number }} \
-Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} \
-Dsonar.pullrequest.github.repository=${GITHUB_REPOSITORY} \
-Dsonar.scm.revision=${{ github.event.pull_request.head.sha }} \
-Dsonar.java.binaries=./target/classes
# Execute Maven enforcer plugin
- name: pom-analyse
run: mvn enforcer:enforce
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 springtainer
Copyright (c) 2022 springtainer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,49 @@
[![Technical dept](https://sonarcloud.io/api/project_badges/measure?project=springtainer_springtainer-mysql&metric=sqale_index)](https://sonarcloud.io/dashboard?id=springtainer_springtainer-mysql)

### Dependency

```xml

<dependency>
<groupId>com.avides.springboot.springtainer</groupId>
<artifactId>springtainer-mysql</artifactId>
<version>1.2.1</version>
<scope>test</scope>
<groupId>com.avides.springboot.springtainer</groupId>
<artifactId>springtainer-mysql</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
```

### Configuration

Properties consumed (in `bootstrap.properties`):

- `embedded.container.mysql.enabled` (default is `true`)
- `embedded.container.mysql.startup-timeout` (default is `30`)
- `embedded.container.mysql.docker-image` (default is `mysql:8.0.20`)
- `embedded.container.mysql.docker-image` (default is `mysql:8.0.28`)
- `embedded.container.mysql.port` (default is `3306`)
- `embedded.container.mysql.root-password` (default is `root`)
- `embedded.container.mysql.database-name` (default is `embeddedMySqlDb`)
- `embedded.container.mysql.database-charset` (default is `utf8mb4`)

Properties provided (in `application-it.properties`):

- `embedded.container.mysql.url` (an alias for `embedded.container.mysql.jdbc-url`)
- `embedded.container.mysql.jdbc-url`
- `embedded.container.mysql.r2dbc-url`
- `embedded.container.mysql.host`
- `embedded.container.mysql.port`

Example for minimal configuration in `application-it.properties`:

```
spring.datasource.url=${embedded.container.mysql.url}
spring.datasource.username=root
spring.datasource.password=${embedded.container.mysql.root-password}
```

## Logging

To reduce logging insert this into the logback-configuration:

```xml
<!-- Springtainer -->
<logger name="com.github.dockerjava.jaxrs" level="WARN" />
Expand All @@ -51,7 +59,9 @@ To reduce logging insert this into the logback-configuration:
```

## Labels

The container exports multiple labels to analyze running springtainers:

- `SPRINGTAINER_SERVICE=mysql`
- `SPRINGTAINER_IMAGE=${embedded.container.mysql.docker-image}`
- `SPRINGTAINER_STARTED=$currentTimestamp`
Loading

0 comments on commit 4e0c350

Please sign in to comment.