Skip to content

Commit cce0ac2

Browse files
add github action pipeline
1 parent 18668bd commit cce0ac2

6 files changed

+278
-0
lines changed

.github/pull_request_template.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
### :scroll: Description
2+
3+
Changes proposed in this pull request:
4+
* ...
5+
6+
### :hammer: Breaking Changes
7+
8+
* Report any api changes
9+
10+
### :white_check_mark: Checklist:
11+
12+
- [ ] Created tests which fail without the change (if possible)
13+
- [ ] Extended the documentation (if necessary)
14+
15+
### :camera_flash: Screenshots
16+
17+
Screenshots to review the UX/UI Design:
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: "Autoupdate PR branches"
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
- "epic/**"
8+
9+
jobs:
10+
autoupdate:
11+
name: autoupdate
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- uses: docker://chinthakagodawita/autoupdate-action:v1
15+
env:
16+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
17+
MERGE_CONFLICT_ACTION: "ignore"

.github/workflows/build-and-test.yml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
pull_request:
8+
branches:
9+
- dev
10+
- beta
11+
- "epic/**"
12+
types: [opened, synchronize, reopened, ready_for_review]
13+
14+
jobs:
15+
build:
16+
name: "Build"
17+
timeout-minutes: 10
18+
19+
if: github.event.pull_request.draft == false
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: "Checkout Branch"
25+
uses: actions/checkout@v3
26+
27+
- name: "Setup Java"
28+
uses: actions/setup-java@v3
29+
with:
30+
distribution: 'temurin'
31+
java-version: 17
32+
cache: 'gradle'
33+
34+
- name: Setup Gradle cache
35+
uses: actions/cache@v3
36+
with:
37+
path: ~/.gradle
38+
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
39+
40+
- name: "prepare libs for build"
41+
run: ./prepare.sh
42+
43+
- name: "build backend"
44+
run: ./gradlew --build-cache build -x test
45+
46+
- name: Upload build reports
47+
uses: actions/upload-artifact@v3
48+
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'force reports') }}
49+
with:
50+
name: Build Reports
51+
path: "**/build/reports"
52+
53+
test:
54+
name: "Test"
55+
timeout-minutes: 120
56+
57+
if: github.event.pull_request.draft == false
58+
needs: build
59+
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: "Checkout Branch"
64+
uses: actions/checkout@v3
65+
66+
- name: "Setup Java"
67+
uses: actions/setup-java@v3
68+
with:
69+
distribution: 'temurin'
70+
java-version: 17
71+
cache: 'gradle'
72+
73+
- name: Setup Gradle cache
74+
uses: actions/cache@v3
75+
with:
76+
path: ~/.gradle
77+
key: ${{ runner.os }}-gradle-${{ hashFiles('versions.properties') }}-${{ github.sha }}
78+
79+
- name: "prepare libs for tests"
80+
run: ./prepare.sh
81+
82+
- name: "test backend"
83+
run: ./gradlew --build-cache check
84+
85+
- name: Upload test reports
86+
uses: actions/upload-artifact@v3
87+
if: ${{ failure() || contains(github.event.pull_request.labels.*.name, 'force reports') }}
88+
with:
89+
name: Test Reports
90+
path: "**/build/reports"

.github/workflows/detekt-analysis.yml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# This workflow performs a static analysis of your Kotlin source code using
2+
# Detekt.
3+
#
4+
# Scans are triggered:
5+
# 1. On every push to default and protected branches
6+
# 2. On every Pull Request targeting the default branch
7+
# 3. On a weekly schedule
8+
# 4. Manually, on demand, via the "workflow_dispatch" event
9+
#
10+
# The workflow should work with no modifications, but you might like to use a
11+
# later version of the Detekt CLI by modifing the $DETEKT_RELEASE_TAG
12+
# environment variable.
13+
name: Scan with Detekt
14+
15+
on:
16+
# Triggers the workflow on push or pull request events but only for default and protected branches
17+
push:
18+
branches: [ dev, beta, stable ]
19+
pull_request:
20+
branches: [ dev ]
21+
schedule:
22+
- cron: '19 11 * * 4'
23+
24+
# Allows you to run this workflow manually from the Actions tab
25+
workflow_dispatch:
26+
27+
env:
28+
# Release tag associated with version of Detekt to be installed
29+
# SARIF support (required for this workflow) was introduced in Detekt v1.15.0
30+
DETEKT_RELEASE_TAG: v1.15.0
31+
32+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
33+
jobs:
34+
# This workflow contains a single job called "scan"
35+
scan:
36+
name: Scan
37+
# The type of runner that the job will run on
38+
runs-on: ubuntu-latest
39+
40+
# Steps represent a sequence of tasks that will be executed as part of the job
41+
steps:
42+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
43+
- uses: actions/checkout@v2
44+
45+
# Gets the download URL associated with the $DETEKT_RELEASE_TAG
46+
- name: Get Detekt download URL
47+
id: detekt_info
48+
env:
49+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: |
51+
DETEKT_DOWNLOAD_URL=$( gh api graphql --field tagName=$DETEKT_RELEASE_TAG --raw-field query='
52+
query getReleaseAssetDownloadUrl($tagName: String!) {
53+
repository(name: "detekt", owner: "detekt") {
54+
release(tagName: $tagName) {
55+
releaseAssets(name: "detekt", first: 1) {
56+
nodes {
57+
downloadUrl
58+
}
59+
}
60+
}
61+
}
62+
}
63+
' | \
64+
jq --raw-output '.data.repository.release.releaseAssets.nodes[0].downloadUrl' )
65+
echo "::set-output name=download_url::$DETEKT_DOWNLOAD_URL"
66+
67+
# Sets up the detekt cli
68+
- name: Setup Detekt
69+
run: |
70+
dest=$( mktemp -d )
71+
curl --request GET \
72+
--url ${{ steps.detekt_info.outputs.download_url }} \
73+
--silent \
74+
--location \
75+
--output $dest/detekt
76+
chmod a+x $dest/detekt
77+
echo $dest >> $GITHUB_PATH
78+
79+
# Performs static analysis using Detekt
80+
- name: Run Detekt
81+
continue-on-error: true
82+
run: |
83+
detekt --input ${{ github.workspace }} --report sarif:${{ github.workspace }}/detekt.sarif.json
84+
85+
# Modifies the SARIF output produced by Detekt so that absolute URIs are relative
86+
# This is so we can easily map results onto their source files
87+
# This can be removed once relative URI support lands in Detekt: https://git.io/JLBbA
88+
- name: Make artifact location URIs relative
89+
continue-on-error: true
90+
run: |
91+
echo "$(
92+
jq \
93+
--arg github_workspace ${{ github.workspace }} \
94+
'. | ( .runs[].results[].locations[].physicalLocation.artifactLocation.uri |= if test($github_workspace) then .[($github_workspace | length | . + 1):] else . end )' \
95+
${{ github.workspace }}/detekt.sarif.json
96+
)" > ${{ github.workspace }}/detekt.sarif.json
97+
98+
# Uploads results to GitHub repository using the upload-sarif action
99+
- uses: github/codeql-action/upload-sarif@v1
100+
with:
101+
# Path to SARIF file relative to the root of the repository
102+
sarif_file: ${{ github.workspace }}/detekt.sarif.json
103+
checkout_path: ${{ github.workspace }}

.github/workflows/publish-jars.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish
2+
on:
3+
release:
4+
types: [created]
5+
push:
6+
branches:
7+
- dev
8+
jobs:
9+
publish:
10+
name: Publish Artifacts
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- name: "Checkout Branch"
17+
uses: actions/checkout@v3
18+
- name: "Setup Java"
19+
uses: actions/setup-java@v3
20+
with:
21+
distribution: 'temurin'
22+
java-version: 17
23+
cache: 'gradle'
24+
- name: Validate Gradle wrapper
25+
uses: gradle/wrapper-validation-action@v1
26+
- name: Publish Packages
27+
uses: gradle/gradle-build-action@v2
28+
with:
29+
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
ORG_GRADLE_PROJECT_OPENBASE_GPG_PRIVATE_KEY: ${{ secrets.OPENBASE_GPG_PRIVATE_KEY }}
33+
ORG_GRADLE_PROJECT_OPENBASE_GPG_PRIVATE_KEY_PASSPHRASE: ""
34+
ORG_GRADLE_PROJECT_MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
35+
ORG_GRADLE_PROJECT_MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}

prepare.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash -e
2+
3+
NC='\033[0m'
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
ORANGE='\033[0;33m'
7+
BLUE='\033[0;34m'
8+
WHITE='\033[0;37m'
9+
10+
APP_NAME='planetsudo engine'
11+
APP_NAME=${BLUE}${APP_NAME}${NC}
12+
echo -e "=== ${APP_NAME} project ${WHITE}cleanup${NC}"
13+
./gradlew clean --quiet $@
14+
echo -e "=== ${APP_NAME} project ${WHITE}installation${NC}"
15+
echo -e "nothing to prepare..."
16+
echo -e "=== ${APP_NAME} was ${GREEN}successfully${NC} installed."

0 commit comments

Comments
 (0)