Skip to content

Commit e36ce5d

Browse files
authored
Download save-agent and save-demo-agent in CI (#2889)
- download `save-agent` and `save-demo-agent` as `save-cli` instead of building as a project dependency
1 parent 34c477d commit e36ce5d

13 files changed

Lines changed: 243 additions & 175 deletions

.github/workflows/backend-api-spec-update.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
build_cli:
11-
name: Build save-cli
12-
uses: ./.github/workflows/build_save-cli_reusable.yml
13-
1410
update_backend_api_spec:
1511
runs-on: ubuntu-latest
16-
needs: build_cli
1712
steps:
1813
- uses: peterjgrainger/action-create-branch@v2.4.0
1914
env:
@@ -37,25 +32,17 @@ jobs:
3732
git config user.name github-actions[bot]
3833
git config user.email 'github-actions[bot]@users.noreply.github.com'
3934
40-
- name: Install system packages
41-
# libcurl is needed for ktor-client-curl
42-
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
43-
4435
- name: Update branch from master
4536
run: |
4637
git pull origin master --no-edit --rebase
4738
4839
# we need save-cli.kexe to start backend, because InternalFileStorage requires it when save-cli has -SNAPSHOT version
49-
- name: Download save-cli
50-
if: ${{ endsWith(needs.build_cli.outputs.version, '-SNAPSHOT') }}
51-
uses: actions/download-artifact@v3
52-
with:
53-
name: save-cli
54-
path: ${{ github.workspace }}/save
55-
- name: Override saveCliVersion and saveCliPath in Gradle
40+
- name: Mock save-cli
5641
if: ${{ endsWith(needs.build_cli.outputs.version, '-SNAPSHOT') }}
5742
run: |
58-
echo SAVE_CLI_GRADLE_OPTS=-PsaveCliVersion=${{ inputs.save-cli-version }} -PsaveCliPath=${{ github.workspace }}/save >> $GITHUB_ENV
43+
mkdir ${{ github.workspace }}/save-cli
44+
touch ${{ github.workspace }}/save-cli/save-cli.kexe
45+
echo SAVE_CLI_GRADLE_OPTS=-PsaveCliPath=${{ github.workspace }}/save-cli >> $GITHUB_ENV
5946
6047
- name: Generate open api doc
6148
uses: gradle/gradle-build-action@v2

.github/workflows/build_and_test_reusable.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ jobs:
4040
key: ${{ runner.os }}-gradle-konan-${{ env.KOTLIN_VERSION }}
4141
- name: Build ${{ inputs.module }}
4242
uses: gradle/gradle-build-action@v2
43-
env:
44-
SKIP_SAVE_AGENT_DEPENDENCY: true
4543
with:
4644
gradle-version: wrapper
4745
gradle-home-cache-cleanup: true
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Reusable build save-agent and save-demo-agent
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch:
7+
type: string
8+
required: true
9+
build-save-agent:
10+
type: boolean
11+
required: true
12+
build-save-demo-agent:
13+
type: boolean
14+
required: true
15+
16+
jobs:
17+
build:
18+
name: Build save-agent and save-demo-agent
19+
if: inputs.build-save-agent || inputs.build-save-demo-agent
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout save-cloud
23+
uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 0
26+
ref: ${{ inputs.branch }}
27+
28+
- name: Prepare to build
29+
run: |
30+
echo SAVE_AGENT_GRADLE_TASK = >> $GITHUB_ENV
31+
echo SAVE_DEMO_AGENT_GRADLE_TASK = >> $GITHUB_ENV
32+
- name: Set save-agent build task
33+
if: inputs.build-save-agent
34+
run: |
35+
echo SAVE_AGENT_GRADLE_TASK=':save-agent:copyAgentDistribution' >> $GITHUB_ENV
36+
- name: Set save-demo-agent build task
37+
if: inputs.build-save-demo-agent
38+
run: |
39+
echo SAVE_DEMO_AGENT_GRADLE_TASK=':save-agent:copyAgentDistribution' >> $GITHUB_ENV
40+
41+
- name: Store Kotlin version in env
42+
run: |
43+
kv=$(cat gradle/libs.versions.toml | grep -m1 '^kotlin =' | awk -F'[=]' '{print $2}' | tr -d '" ')
44+
echo KOTLIN_VERSION=$kv >> $GITHUB_ENV
45+
- name: Cache konan
46+
uses: actions/cache@v3
47+
with:
48+
path: ~/.konan
49+
key: ${{ runner.os }}-gradle-konan-${{ env.KOTLIN_VERSION }}
50+
- name: Set up JDK 17
51+
uses: actions/setup-java@v4
52+
with:
53+
java-version: 17
54+
distribution: temurin
55+
- name: Install system packages
56+
# libcurl is needed for ktor-client-curl
57+
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
58+
59+
- name: Build save-agent and save-demo-agent
60+
uses: gradle/gradle-build-action@v2
61+
with:
62+
gradle-version: wrapper
63+
arguments: |
64+
${{ env.SAVE_AGENT_GRADLE_TASK }}
65+
${{ env.SAVE_DEMO_AGENT_GRADLE_TASK }}
66+
--stacktrace
67+
--build-cache
68+
-Pdetekt.multiplatform.disabled=true
69+
-x detekt
70+
-x spotlessCheck
71+
-PgprUser=${{ github.actor }}
72+
-PgprKey=${{ secrets.GITHUB_TOKEN }}
73+
74+
- name: Upload save-agent
75+
if: inputs.build-save-agent
76+
uses: actions/upload-artifact@v3
77+
with:
78+
name: save-agent
79+
path: 'save-agent/build/libs/save-agent-*-distribution.jar'
80+
- name: Upload save-demo-agent
81+
if: inputs.build-save-demo-agent
82+
uses: actions/upload-artifact@v3
83+
with:
84+
name: save-demo-agent
85+
path: 'save-demo-agent/build/libs/save-demo-agent-*-distribution.jar'
86+
87+
- name: Upload gradle reports
88+
if: ${{ always() }}
89+
uses: actions/upload-artifact@v3
90+
with:
91+
name: gradle-reports
92+
path: '**/build/reports/'
93+
retention-days: 1

.github/workflows/deploy_images.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ on:
2828
default: true
2929
description: Build new image of save-frontend
3030
required: false
31+
cosv-frontend:
32+
type: boolean
33+
default: true
34+
description: Build new image of save-cosv-frontend
35+
required: false
3136
orchestrator:
3237
type: boolean
3338
default: true
@@ -59,10 +64,18 @@ jobs:
5964
name: Build save-cli
6065
uses: ./.github/workflows/build_save-cli_reusable.yml
6166

67+
build_agents:
68+
name: Build save-agent and save-demo-agent
69+
uses: ./.github/workflows/build_save-agent_reusable.yml
70+
with:
71+
branch: ${{ inputs.branch }}
72+
build-save-agent: ${{ inputs.backend || inputs.sandbox }}
73+
build-save-demo-agent: ${{ inputs.demo }}
74+
6275
deploy_backend:
6376
name: save-backend
6477
uses: ./.github/workflows/deploy_images_reusable.yml
65-
needs: build_cli
78+
needs: [ build_cli, build_agents ]
6679
with:
6780
module: save-backend
6881
branch: ${{ inputs.branch }}
@@ -73,38 +86,49 @@ jobs:
7386
deploy_sandbox:
7487
name: save-sandbox
7588
uses: ./.github/workflows/deploy_images_reusable.yml
76-
needs: build_cli
89+
needs: [ build_cli, build_agents ]
7790
with:
7891
module: save-sandbox
7992
branch: ${{ inputs.branch }}
8093
do-build: ${{ github.event_name != 'workflow_dispatch' || inputs.sandbox }}
8194
override-docker-tag: ${{ github.event_name == 'workflow_dispatch' }}
8295
save-cli-version: ${{ needs.build_cli.outputs.version }}
8396

97+
deploy_demo:
98+
name: save-demo
99+
uses: ./.github/workflows/deploy_images_reusable.yml
100+
needs: build_agents
101+
with:
102+
module: save-demo
103+
branch: ${{ inputs.branch }}
104+
do-build: ${{ github.event_name != 'workflow_dispatch' || inputs.demo }}
105+
override-docker-tag: ${{ github.event_name == 'workflow_dispatch' }}
106+
save-cli-version: stub
107+
84108
deploy_all:
85-
name: all excluding save-backend and save-sandbox
109+
name: all excluding save-backend, save-sandbox and save-demo
86110
strategy:
87111
fail-fast: false
88112
matrix:
89113
module: [
90114
'api-gateway',
91115
'save-frontend',
116+
'save-cosv-frontend',
92117
'save-orchestrator',
93118
'save-preprocessor',
94-
'save-demo',
95119
'save-demo-cpg',
96120
]
97121
include:
98122
- module: api-gateway
99123
do-build: ${{ inputs.gateway }}
100124
- module: save-frontend
101125
do-build: ${{ inputs.frontend }}
126+
- module: save-cosv-frontend
127+
do-build: ${{ inputs.cosv-frontend }}
102128
- module: save-orchestrator
103129
do-build: ${{ inputs.orchestrator }}
104130
- module: save-preprocessor
105131
do-build: ${{ inputs.preprocessor }}
106-
- module: save-demo
107-
do-build: ${{ inputs.demo }}
108132
- module: save-demo-cpg
109133
do-build: ${{ inputs.demo-cpg }}
110134
uses: ./.github/workflows/deploy_images_reusable.yml

.github/workflows/deploy_images_reusable.yml

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,18 @@ jobs:
3232
uses: actions/checkout@v3
3333
with:
3434
fetch-depth: 0
35+
ref: ${{ inputs.branch }}
3536
- name: Prepare to build
3637
run: |
3738
echo ADDITIONAL_GRADLE_OPTS= >> $GITHUB_ENV
3839
echo SAVE_CLI_GRADLE_OPTS= >> $GITHUB_ENV
40+
echo SAVE_AGENT_GRADLE_OPTS = >> $GITHUB_ENV
41+
echo SAVE_DEMO_AGENT_GRADLE_OPTS = >> $GITHUB_ENV
3942
echo GRADLE_TASKS=:${{ inputs.module}}:bootBuildImage >> $GITHUB_ENV
4043
- name: Override gradle command for frontend
41-
if: inputs.module == 'save-frontend'
44+
if: inputs.module == 'save-frontend' || inputs.module == 'save-cosv-frontend'
4245
run: |
4346
echo GRADLE_TASKS=:${{ inputs.module}}:buildImage >> $GITHUB_ENV
44-
- name: Prepare to build from branch
45-
if: inputs.branch
46-
run: |
47-
git checkout origin/${{ inputs.branch }}
4847
- name: Override dockerTag
4948
if: inputs.override-docker-tag
5049
run: |
@@ -63,24 +62,42 @@ jobs:
6362
with:
6463
java-version: 17
6564
distribution: temurin
66-
- name: Install system packages
67-
if: inputs.module == 'save-backend' || inputs.module == 'save-sandbox' || inputs.module == 'save-demo'
68-
# libcurl is needed for ktor-client-curl
69-
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
65+
7066
- name: Download save-cli
7167
if: ${{ endsWith(inputs.save-cli-version, '-SNAPSHOT') }}
7268
uses: actions/download-artifact@v3
7369
with:
7470
name: save-cli
75-
path: ${{ github.workspace }}/save
76-
- name: Override saveCliVersion and saveCliPath in Gradle
71+
path: ${{ github.workspace }}/save-cli
72+
- name: Set saveCliVersion and saveCliPath in Gradle
7773
if: ${{ endsWith(inputs.save-cli-version, '-SNAPSHOT') }}
7874
run: |
79-
echo SAVE_CLI_GRADLE_OPTS=-PsaveCliVersion=${{ inputs.save-cli-version }} -PsaveCliPath=${{ github.workspace }}/save >> $GITHUB_ENV
75+
echo SAVE_CLI_GRADLE_OPTS=-PsaveCliVersion=${{ inputs.save-cli-version }} -PsaveCliPath=${{ github.workspace }}/save-cli >> $GITHUB_ENV
76+
77+
- name: Download save-agent
78+
if: inputs.module == 'save-backend' || inputs.module == 'save-sandbox'
79+
uses: actions/download-artifact@v3
80+
with:
81+
name: save-agent
82+
path: ${{ github.workspace }}/save-agent
83+
- name: Set saveAgentPath in Gradle
84+
if: inputs.module == 'save-backend' || inputs.module == 'save-sandbox'
85+
run: |
86+
echo SAVE_AGENT_GRADLE_OPTS=-PsaveAgentPath=${{ github.workspace }}/save-agent >> $GITHUB_ENV
87+
88+
- name: Download save-demo-agent
89+
if: inputs.module == 'save-demo'
90+
uses: actions/download-artifact@v3
91+
with:
92+
name: save-demo-agent
93+
path: ${{ github.workspace }}/save-demo-agent
94+
- name: Set saveDemoAgentPath in Gradle
95+
if: inputs.module == 'save-demo'
96+
run: |
97+
echo SAVE_DEMO_AGENT_GRADLE_OPTS=-PsaveDemoAgentPath=${{ github.workspace }}/save-demo-agent >> $GITHUB_ENV
98+
8099
- name: Build image for ${{ inputs.module }}
81100
uses: gradle/gradle-build-action@v2
82-
env:
83-
DOWNLOAD_SAVE_CLI_DEPENDENCY: true
84101
with:
85102
gradle-version: wrapper
86103
arguments: |
@@ -91,21 +108,9 @@ jobs:
91108
-PgprUser=${{ github.actor }}
92109
-PgprKey=${{ secrets.GITHUB_TOKEN }}
93110
${{ env.SAVE_CLI_GRADLE_OPTS }}
111+
${{ env.SAVE_AGENT_GRADLE_OPTS }}
112+
${{ env.SAVE_DEMO_AGENT_GRADLE_OPTS }}
94113
${{ env.ADDITIONAL_GRADLE_OPTS }}
95-
- name: Upload save-agent-distribution.jar
96-
if: inputs.module == 'save-backend'
97-
uses: actions/upload-artifact@v3
98-
with:
99-
name: save-agent-distribution
100-
path: 'save-agent/build/libs/save-agent-*-distribution.jar'
101-
retention-days: 5
102-
- name: Upload save-demo-agent-distribution.jar
103-
if: inputs.module == 'save-demo'
104-
uses: actions/upload-artifact@v3
105-
with:
106-
name: save-demo-agent-distribution
107-
path: 'save-demo-agent/build/libs/save-demo-agent-*-distribution.jar'
108-
retention-days: 5
109114
- name: Upload gradle reports
110115
if: ${{ always() }}
111116
uses: actions/upload-artifact@v3

gradle/libs.versions.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ spotless = "6.22.0"
3737
fabric8 = "6.9.2"
3838
arrow-kt = "1.2.1"
3939
publish = "1.3.0"
40-
download = "5.5.0"
4140
cpg = "7.1.2"
4241
# should be taken from cpg
4342
cpg-neo4j-ogm = { strictly = "4.0.6" }
@@ -55,7 +54,6 @@ kotlin-plugin-allopen = { id = "org.jetbrains.kotlin.plugin.allopen", version.re
5554
talaiot-base = { id = "io.github.cdsap.talaiot.plugin.base", version = "2.0.3" }
5655
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
5756
spotless = { id = "com.diffplug.gradle.spotless", version.ref = "spotless" }
58-
download = { id = "de.undercouch.download", version.ref = "download" }
5957

6058
[libraries]
6159
save-common = { module = "com.saveourtool.save:save-common", version.ref = "save-cli" }
@@ -68,7 +66,6 @@ save-plugins-warn-jvm = { module = "com.saveourtool.save:warn-plugin-jvm", versi
6866
save-plugins-fixAndWarn-jvm = { module = "com.saveourtool.save:fix-and-warn-plugin-jvm", version.ref = "save-cli" }
6967
save-reporters = { module = "com.saveourtool.save:save-reporters", version.ref = "save-cli" }
7068
publish-gradle-plugin = { module = "io.github.gradle-nexus:publish-plugin", version.ref = "publish"}
71-
download-plugin = { module = "de.undercouch:gradle-download-task", version.ref = "download" }
7269

7370
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
7471
kotlin-plugin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }

gradle/plugins/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ dependencies {
1515
implementation(libs.kotlin.gradle.plugin)
1616
implementation(libs.spring.boot.gradle.plugin)
1717
implementation(libs.kotlin.plugin.allopen)
18-
implementation(libs.download.plugin)
1918
implementation(libs.reckon.gradle.plugin)
2019
implementation(libs.detekt.gradle.plugin)
2120
implementation(libs.diktat.gradle.plugin)

0 commit comments

Comments
 (0)