various fixes...

This commit is contained in:
Aleksandr Chikovani 2023-09-06 21:50:47 -04:00
parent 29db706b76
commit 8dea71883b
3 changed files with 332 additions and 330 deletions

View file

@ -1,226 +1,226 @@
name: Release version #name: Release version
#
on: #on:
push: # push:
branches: [ development, release-* ] # branches: [ development, release-* ]
#
env: #env:
IMAGE_NAME: ${{ github.repository }} # IMAGE_NAME: ${{ github.repository }}
#
jobs: #jobs:
style_checks: # style_checks:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
#
steps: # steps:
- uses: actions/checkout@v3 # - uses: actions/checkout@v3
- name: Set up JDK ${{matrix.java}} # - name: Set up JDK ${{matrix.java}}
uses: actions/setup-java@v2 # uses: actions/setup-java@v2
with: # with:
java-version: '17' # java-version: '17'
distribution: 'temurin' # distribution: 'temurin'
- name: Codestyle # - name: Codestyle
continue-on-error: true #TODO: make false # continue-on-error: true #TODO: make false
run: ./gradlew checkstyleMain # run: ./gradlew checkstyleMain
#
code_checks: # code_checks:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
#
#TODO: cache for libs # #TODO: cache for libs
steps: # steps:
- uses: actions/checkout@v3 # - uses: actions/checkout@v3
- name: Set up JDK ${{matrix.java}} # - name: Set up JDK ${{matrix.java}}
uses: actions/setup-java@v2 # uses: actions/setup-java@v2
with: # with:
java-version: '17' # java-version: '17'
distribution: 'temurin' # distribution: 'temurin'
- name: Test # - name: Test
run: ./gradlew test # run: ./gradlew test
- name: Build # - name: Build
run: ./gradlew build # run: ./gradlew build
#
build_and_publish: # build_and_publish:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
outputs: # outputs:
next_version: ${{ steps.semantic.outputs.next_version }} # next_version: ${{ steps.semantic.outputs.next_version }}
permissions: # permissions:
contents: write # contents: write
packages: write # packages: write
#
steps: # steps:
- name: Checkout repository # - name: Checkout repository
uses: actions/checkout@v3 # uses: actions/checkout@v3
with: # with:
fetch-depth: 0 # fetch-depth: 0
#
- name: Calculate version # - name: Calculate version
id: semantic # id: semantic
run: | # run: |
set -x # set -x
function bump_version { # function bump_version {
# Split the version string into Major, Minor and Patch numbers # # Split the version string into Major, Minor and Patch numbers
local VERSION # local VERSION
IFS='.' read -r -a VERSION <<< $(echo ${1//"v"}) # IFS='.' read -r -a VERSION <<< $(echo ${1//"v"})
local BRANCH_NAME="$2" # local BRANCH_NAME="$2"
local MAJOR=${VERSION[0]} # local MAJOR=${VERSION[0]}
local MINOR=${VERSION[1]} # local MINOR=${VERSION[1]}
local PATCH=${VERSION[2]} # local PATCH=${VERSION[2]}
#
# Increment the version number # # Increment the version number
if [[ "$BRANCH_NAME" == "development" ]]; then # if [[ "$BRANCH_NAME" == "development" ]]; then
MINOR=$((MINOR + 1)) # MINOR=$((MINOR + 1))
PATCH=0 # PATCH=0
rc="-rc" # rc="-rc"
elif [[ "$BRANCH_NAME" == release-* ]]; then # elif [[ "$BRANCH_NAME" == release-* ]]; then
PATCH=$((PATCH + 1)) # PATCH=$((PATCH + 1))
rc="" # rc=""
fi # fi
#
# Build the new version string # # Build the new version string
echo "v${MAJOR}.${MINOR}.${PATCH}${rc}" # echo "v${MAJOR}.${MINOR}.${PATCH}${rc}"
} # }
#
CURRENT_BRANCH=$(git symbolic-ref -q HEAD) # CURRENT_BRANCH=$(git symbolic-ref -q HEAD)
CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} # CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/}
CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} # CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD}
git fetch --tags # git fetch --tags
#
TAGS=$(git tag) # TAGS=$(git tag)
HAS_TAGS=$(echo "$TAGS" | wc -l | tr -d ' ') # HAS_TAGS=$(echo "$TAGS" | wc -l | tr -d ' ')
#
if [[ "$HAS_TAGS" -eq 0 ]]; then # if [[ "$HAS_TAGS" -eq 0 ]]; then
# No tags found # # No tags found
if [[ "$CURRENT_BRANCH" == "development" ]]; then # if [[ "$CURRENT_BRANCH" == "development" ]]; then
# For development branch with no tags, set the next version to 0.1.0-rc # # For development branch with no tags, set the next version to 0.1.0-rc
NEXT_VERSION="v0.1.0-rc" # NEXT_VERSION="v0.1.0-rc"
fi # fi
else # else
# Tags found # # Tags found
if [[ "$CURRENT_BRANCH" == "development" ]]; then # if [[ "$CURRENT_BRANCH" == "development" ]]; then
CURRENT_VERSION=$(git tag | sort -V | tail -1) # CURRENT_VERSION=$(git tag | sort -V | tail -1)
NEXT_VERSION=$(bump_version "${CURRENT_VERSION}" "${CURRENT_BRANCH}") # NEXT_VERSION=$(bump_version "${CURRENT_VERSION}" "${CURRENT_BRANCH}")
elif [[ "${CURRENT_BRANCH}" == release-* ]]; then # elif [[ "${CURRENT_BRANCH}" == release-* ]]; then
# For release branch with tags, bump patch version, e.g. v2.3.4 -> v2.3.5 # # For release branch with tags, bump patch version, e.g. v2.3.4 -> v2.3.5
CURRENT_VERSION=$(git tag | grep "^v${CURRENT_BRANCH#'release-'}.*" | sort -V | tail -1) # CURRENT_VERSION=$(git tag | grep "^v${CURRENT_BRANCH#'release-'}.*" | sort -V | tail -1)
if [[ -n "$CURRENT_VERSION" ]]; then # if [[ -n "$CURRENT_VERSION" ]]; then
NEXT_VERSION=$(bump_version "${CURRENT_VERSION}" "${CURRENT_BRANCH}") # NEXT_VERSION=$(bump_version "${CURRENT_VERSION}" "${CURRENT_BRANCH}")
else # else
# If no tags match the release branch, set the next version to release number with 0 patch version, e.g. v-0.1.0 # # If no tags match the release branch, set the next version to release number with 0 patch version, e.g. v-0.1.0
NEXT_VERSION="v${CURRENT_BRANCH#'release-'}.0" # NEXT_VERSION="v${CURRENT_BRANCH#'release-'}.0"
fi # fi
else # else
exit 2 # exit 2
fi # fi
fi # fi
#
echo "current_version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT # echo "current_version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
echo "next_version=${NEXT_VERSION}" >> $GITHUB_OUTPUT # echo "next_version=${NEXT_VERSION}" >> $GITHUB_OUTPUT
#
release: # release:
needs: build_and_publish # needs: build_and_publish
runs-on: ubuntu-latest # runs-on: ubuntu-latest
environment: # environment:
name: release # name: release
permissions: # permissions:
contents: write # contents: write
packages: write # packages: write
#
steps: # steps:
- name: Checkout repository # - name: Checkout repository
uses: actions/checkout@v3 # uses: actions/checkout@v3
with: # with:
fetch-depth: 0 # fetch-depth: 0
#
- name: "Build Changelog" # - name: "Build Changelog"
id: build_changelog # id: build_changelog
run: | # run: |
set -x # set -x
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null|| echo NO ) # LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null|| echo NO )
#
if [[ "${LAST_TAG}" == "NO" ]]; then # if [[ "${LAST_TAG}" == "NO" ]]; then
git log --pretty=format:"%s" > /tmp/my_commits_log_all # git log --pretty=format:"%s" > /tmp/my_commits_log_all
else # else
git log "${LAST_TAG}"..HEAD --pretty=format:"%s" > /tmp/my_commits_log_all # git log "${LAST_TAG}"..HEAD --pretty=format:"%s" > /tmp/my_commits_log_all
fi # fi
#
cat /tmp/my_commits_log_all | sort > /tmp/my_commits_log # cat /tmp/my_commits_log_all | sort > /tmp/my_commits_log
#
echo -n '' > /tmp/my_changelog_features # echo -n '' > /tmp/my_changelog_features
echo -n '' > /tmp/my_changelog_fixes # echo -n '' > /tmp/my_changelog_fixes
echo -n '' > /tmp/my_changelog_other # echo -n '' > /tmp/my_changelog_other
echo -n '' > /tmp/my_changelog # echo -n '' > /tmp/my_changelog
#
FEATURES_REGEX="^feat:|^feature:" # FEATURES_REGEX="^feat:|^feature:"
FIXES_REGEX="^fix:|^hotfix:" # FIXES_REGEX="^fix:|^hotfix:"
#
egrep "${FEATURES_REGEX}" /tmp/my_commits_log | while read l; do # egrep "${FEATURES_REGEX}" /tmp/my_commits_log | while read l; do
DESCRIPTION=$(echo "${l}" | sed "s/^feat://;s/^feature://") # DESCRIPTION=$(echo "${l}" | sed "s/^feat://;s/^feature://")
echo "* ${DESCRIPTION}" >> /tmp/my_changelog_features # echo "* ${DESCRIPTION}" >> /tmp/my_changelog_features
export FEATURES_ENABLED=1 # export FEATURES_ENABLED=1
done # done
#
egrep "${FIXES_REGEX}" /tmp/my_commits_log | while read l; do # egrep "${FIXES_REGEX}" /tmp/my_commits_log | while read l; do
DESCRIPTION=$(echo "${l}" | sed "s/^fix://;s/^hotfix://") # DESCRIPTION=$(echo "${l}" | sed "s/^fix://;s/^hotfix://")
echo "* ${DESCRIPTION}" >> /tmp/my_changelog_fixes # echo "* ${DESCRIPTION}" >> /tmp/my_changelog_fixes
export FIXES_ENABLED=1 # export FIXES_ENABLED=1
done # done
#
egrep -v "${FEATURES_REGEX}|${FIXES_REGEX}" /tmp/my_commits_log | while read l; do # egrep -v "${FEATURES_REGEX}|${FIXES_REGEX}" /tmp/my_commits_log | while read l; do
echo "* ${l}" >> /tmp/my_changelog_other # echo "* ${l}" >> /tmp/my_changelog_other
export OTHER_ENABLED=1 # export OTHER_ENABLED=1
done # done
#
if [[ "$(wc -l /tmp/my_changelog_features | awk '{print $1}')" -gt 0 ]] ; then # if [[ "$(wc -l /tmp/my_changelog_features | awk '{print $1}')" -gt 0 ]] ; then
echo "### Features:" >> /tmp/my_changelog # echo "### Features:" >> /tmp/my_changelog
cat /tmp/my_changelog_features >> /tmp/my_changelog # cat /tmp/my_changelog_features >> /tmp/my_changelog
echo "" >> /tmp/my_changelog # echo "" >> /tmp/my_changelog
fi # fi
#
if [[ "$(wc -l /tmp/my_changelog_fixes | awk '{print $1}')" -gt 0 ]] ; then # if [[ "$(wc -l /tmp/my_changelog_fixes | awk '{print $1}')" -gt 0 ]] ; then
echo "### Fixes:" >> /tmp/my_changelog # echo "### Fixes:" >> /tmp/my_changelog
cat /tmp/my_changelog_fixes >> /tmp/my_changelog # cat /tmp/my_changelog_fixes >> /tmp/my_changelog
echo "" >> /tmp/my_changelog # echo "" >> /tmp/my_changelog
fi # fi
#
if [[ "$(wc -l /tmp/my_changelog_other | awk '{print $1}')" -gt 0 ]] ; then # if [[ "$(wc -l /tmp/my_changelog_other | awk '{print $1}')" -gt 0 ]] ; then
echo "### Other:" >> /tmp/my_changelog # echo "### Other:" >> /tmp/my_changelog
cat /tmp/my_changelog_other >> /tmp/my_changelog # cat /tmp/my_changelog_other >> /tmp/my_changelog
echo "" >> /tmp/my_changelog # echo "" >> /tmp/my_changelog
fi # fi
#
MY_CHANGELOG=$(cat /tmp/my_changelog) # MY_CHANGELOG=$(cat /tmp/my_changelog)
MY_CHANGELOG="${MY_CHANGELOG//'%'/'%25'}" # MY_CHANGELOG="${MY_CHANGELOG//'%'/'%25'}"
MY_CHANGELOG="${MY_CHANGELOG//$'\n'/'%0A'}" # MY_CHANGELOG="${MY_CHANGELOG//$'\n'/'%0A'}"
MY_CHANGELOG="${MY_CHANGELOG//$'\r'/'%0D'}" # MY_CHANGELOG="${MY_CHANGELOG//$'\r'/'%0D'}"
{ # {
echo "CHANGELOG<<EOF" # echo "CHANGELOG<<EOF"
cat /tmp/my_changelog # cat /tmp/my_changelog
echo "EOF" # echo "EOF"
} >> "$GITHUB_ENV" # } >> "$GITHUB_ENV"
#
- name: Login to GitHub Container Registry # - name: Login to GitHub Container Registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with: # with:
registry: ghcr.io # registry: ghcr.io
username: ${{ github.actor }} # username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} # password: ${{ secrets.GITHUB_TOKEN }}
#
- name: Build and push Docker image # - name: Build and push Docker image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
with: # with:
context: . # context: .
push: true # push: true
tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ steps.semantic.outputs.release-version }} # tags: ghcr.io/${{ env.IMAGE_NAME }}:${{ steps.semantic.outputs.release-version }}
labels: ${{ steps.meta.outputs.labels }} # labels: ${{ steps.meta.outputs.labels }}
build-args: | # build-args: |
VERSION=${{ steps.semantic.outputs.release-version }} # VERSION=${{ steps.semantic.outputs.release-version }}
#
#
- name: Release # - name: Release
uses: softprops/action-gh-release@v1 # uses: softprops/action-gh-release@v1
with: # with:
target_commitish: ${{ github.sha }} # target_commitish: ${{ github.sha }}
tag_name: ${{ needs.build_and_publish.outputs.next_version }} # tag_name: ${{ needs.build_and_publish.outputs.next_version }}
body: | # body: |
# ${{ needs.build_and_publish.outputs.next_version }} # # ${{ needs.build_and_publish.outputs.next_version }}
#
${{ env.CHANGELOG }} # ${{ env.CHANGELOG }}

View file

@ -1,103 +1,103 @@
name: Java test build #name: Java test build
#
on: #on:
pull_request: # pull_request:
branches: [ development, release/** ] # branches: [ development, release/** ]
#
env: #env:
IMAGE_NAME: ${{ github.repository }} # IMAGE_NAME: ${{ github.repository }}
#
jobs: #jobs:
style_checks: # style_checks:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
#
steps: # steps:
- name: PR title check # - name: PR title check
uses: thehanimo/pr-title-checker@v1.4.0 # uses: thehanimo/pr-title-checker@v1.4.0
with: # with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3 # - uses: actions/checkout@v3
- name: Set up JDK ${{matrix.java}} # - name: Set up JDK ${{matrix.java}}
uses: actions/setup-java@v2 # uses: actions/setup-java@v2
with: # with:
java-version: '17' # java-version: '17'
distribution: 'temurin' # distribution: 'temurin'
- name: Codestyle # - name: Codestyle
continue-on-error: true #TODO: make false # continue-on-error: true #TODO: make false
run: ./gradlew checkstyleMain # run: ./gradlew checkstyleMain
#
code_checks: # code_checks:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
#
#TODO: cache for libs # #TODO: cache for libs
steps: # steps:
- uses: actions/checkout@v3 # - uses: actions/checkout@v3
- name: Set up JDK ${{matrix.java}} # - name: Set up JDK ${{matrix.java}}
uses: actions/setup-java@v2 # uses: actions/setup-java@v2
with: # with:
java-version: '17' # java-version: '17'
distribution: 'temurin' # distribution: 'temurin'
- name: Test # - name: Test
run: ./gradlew test # run: ./gradlew test
- name: Build # - name: Build
run: ./gradlew build -x test -x processTestAot -x checkstyleMain -x checkstyleTest -x checkstyleAot -x checkstyleAotTest # run: ./gradlew build -x test -x processTestAot -x checkstyleMain -x checkstyleTest -x checkstyleAot -x checkstyleAotTest
#
docker_build: # docker_build:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
#
steps: # steps:
- uses: actions/checkout@v3 # - uses: actions/checkout@v3
- name: Build Docker image # - name: Build Docker image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 # uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
with: # with:
context: . # context: .
push: false # push: false
tags: ghcr.io/${{ env.IMAGE_NAME }}:test # tags: ghcr.io/${{ env.IMAGE_NAME }}:test
- name: Run Trivy vulnerability scanner # - name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master # uses: aquasecurity/trivy-action@master
with: # with:
image-ref: 'ghcr.io/${{ env.IMAGE_NAME }}:test' # image-ref: 'ghcr.io/${{ env.IMAGE_NAME }}:test'
format: 'table' # format: 'table'
exit-code: '1' # exit-code: '1'
ignore-unfixed: true # ignore-unfixed: true
vuln-type: 'os,library' # vuln-type: 'os,library'
severity: 'CRITICAL,HIGH' # severity: 'CRITICAL,HIGH'
#
ort: # ort:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
#
steps: # steps:
- name: Use HTTPS instead of SSH for Git cloning # - name: Use HTTPS instead of SSH for Git cloning
run: git config --global url.https://github.com/.insteadOf ssh://git@github.com/ # run: git config --global url.https://github.com/.insteadOf ssh://git@github.com/
- name: Checkout project # - name: Checkout project
uses: actions/checkout@v3 # uses: actions/checkout@v3
- name: Run GitHub Action for ORT # - name: Run GitHub Action for ORT
id: ort_scan # id: ort_scan
uses: oss-review-toolkit/ort-ci-github-action@v1 # uses: oss-review-toolkit/ort-ci-github-action@v1
continue-on-error: true # continue-on-error: true
with: # with:
allow-dynamic-versions: 'true' # allow-dynamic-versions: 'true'
fail-on: 'violations' # fail-on: 'violations'
- name: Show status of ORT # - name: Show status of ORT
if: ${{ steps.ort_scan.outcome == 'failure' }} # if: ${{ steps.ort_scan.outcome == 'failure' }}
run: | # run: |
echo "status_color=yellow" >> $GITHUB_ENV # echo "status_color=yellow" >> $GITHUB_ENV
echo "::error::ORT Scan failed, see logs and artifacts" # echo "::error::ORT Scan failed, see logs and artifacts"
#
#
codeql: # codeql:
runs-on: ubuntu-latest # runs-on: ubuntu-latest
#
steps: # steps:
- name: Checkout repository # - name: Checkout repository
uses: actions/checkout@v3 # uses: actions/checkout@v3
- name: Initialize CodeQL # - name: Initialize CodeQL
uses: github/codeql-action/init@v2 # uses: github/codeql-action/init@v2
with: # with:
languages: 'java' # languages: 'java'
- name: Autobuild # - name: Autobuild
uses: github/codeql-action/autobuild@v2 # uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis # - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 # uses: github/codeql-action/analyze@v2
with: # with:
category: '/language:java' # category: '/language:java'

View file

@ -3,6 +3,8 @@ name: Trigger tests
on: on:
pull_request: pull_request:
branches: [ development, release/** ] branches: [ development, release/** ]
issue_comment:
types: [created]
env: env:
IMAGE_NAME: ${{ github.repository }} IMAGE_NAME: ${{ github.repository }}
@ -13,7 +15,7 @@ jobs:
steps: steps:
- name: Build - name: Build
if: ${{ github.actor == 'justrp' }} if: github.event.issue.pull_request && github.actor == 'justrp'
env: env:
PR_NUMBER: ${{ github.event.number }} PR_NUMBER: ${{ github.event.number }}
PR_REF_OWNER: ${{ github.event.pull_request.head.repo.owner.login }} PR_REF_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}