Skip to content

Commit 843522c

Browse files
Add an option to enable verbosity
Fixes #93
1 parent 71351d3 commit 843522c

File tree

8 files changed

+107
-28
lines changed

8 files changed

+107
-28
lines changed

.github/workflows/flatpak-test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
restore-cache: ${{ matrix.restore == 'cache-restored' }}
4444
cache-key: flatpak-builder-${{ github.sha }}-${{ matrix.restore }}
4545
arch: ${{ matrix.arch }}
46+
verbose: true
4647
# TODO: setup a flat-manager before and use it later here
4748
#- uses: ./flat-manager
4849
# with:
@@ -63,6 +64,7 @@ jobs:
6364
manifest-path: ./flatpak-builder/tests/test-project/org.example.MyApp.yaml
6465
stop-at-module: testproject
6566
cache: false
67+
verbose: true
6668

6769
flatpak-builder-cache-hit:
6870
name: Flatpak Builder Cache Hit
@@ -78,6 +80,7 @@ jobs:
7880
bundle: org.example.MyApp.Devel-cache-hit.flatpak
7981
manifest-path: ./flatpak-builder/tests/test-project/org.example.MyApp.yaml
8082
cache-key: flatpak-builder-${{ github.sha }}-no-cache-restored
83+
verbose: true
8184

8285
tests:
8386
name: Tests

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
| `arch` | Specifies the CPU architecture to build for | Optional | `x86_64` |
5555
| `mirror-screenshots-url` | Specifies the URL to mirror screenshots | Optional | - |
5656
| `gpg-sign` | The key to sign the package | Optional | - |
57+
| `verbose` | Enable verbosity | Optional | `false` |
5758

5859
#### Building for multiple CPU architectures
5960

@@ -184,6 +185,7 @@ jobs:
184185
| `token` | A flat-manager token | Required | - |
185186
| `end-of-life` | Reason for end of life | Optional | - |
186187
| `end-of-life-rebase` | The new app-id | Optional | - |
188+
| `verbose` | Enable verbosity | Optional | `false` |
187189

188190
### Docker Image
189191

flat-manager/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ inputs:
2525
description: >
2626
"Mark new refs as end-of-life. This one takes an ID that supersedes the current one. By the user's request, the application data may be preserved for the new application. Note, this is actually a prefix match, so if you say org.the.app=org.new.app, then something like org.the.app.Locale will be rebased to org.new.app.Locale."
2727
required: false
28+
verbose:
29+
description: >
30+
"Enable verbosity"
31+
required: false
32+
default: "false"
2833
runs:
2934
using: "node16"
3035
main: "dist/index.js"

flat-manager/dist/index.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4099,15 +4099,21 @@ class Configuration {
40994099
this.endOfLifeRebase = core.getInput('end-of-life-rebase')
41004100
// FIXME: get this from the outputs of the flatpak-builder action
41014101
this.localRepoName = 'repo'
4102+
// Verbosity
4103+
this.verbose = core.getBooleanInput('verbose') || false
41024104
}
41034105
}
41044106

41054107
const run = (config) => {
4106-
exec.exec('flatpak', [
4108+
const args = [
41074109
'build-update-repo',
41084110
'--generate-static-deltas',
41094111
config.localRepoName
4110-
])
4112+
]
4113+
if (config.verbose) {
4114+
args.push('-vv', '--ostree-verbose')
4115+
}
4116+
exec.exec('flatpak', args)
41114117
.then(async () => {
41124118
let buildId = ''
41134119
let args = [
@@ -4133,6 +4139,10 @@ const run = (config) => {
41334139
config.repository
41344140
])
41354141

4142+
if (config.verbose) {
4143+
args.push('--verbose')
4144+
}
4145+
41364146
const exitCode = await exec.exec('flat-manager-client', args, {
41374147
listeners: {
41384148
stdout: (data) => {
@@ -4146,7 +4156,7 @@ const run = (config) => {
41464156
return buildId
41474157
})
41484158
.then(async (buildId) => {
4149-
await exec.exec('flat-manager-client', [
4159+
const args = [
41504160
'--token',
41514161
config.token,
41524162
'push',
@@ -4155,16 +4165,25 @@ const run = (config) => {
41554165
'--wait',
41564166
buildId,
41574167
config.localRepoName
4158-
])
4168+
]
4169+
if (config.verbose) {
4170+
args.push('--verbose')
4171+
}
4172+
await exec.exec('flat-manager-client', args)
41594173
return buildId
41604174
})
41614175
.then(async (buildId) => {
4162-
await exec.exec('flat-manager-client', [
4176+
const args = [
41634177
'--token',
41644178
config.token,
41654179
'purge',
41664180
buildId
4167-
])
4181+
]
4182+
4183+
if (config.verbose) {
4184+
args.push('--verbose')
4185+
}
4186+
await exec.exec('flat-manager-client', args)
41684187
})
41694188
.catch((err) => {
41704189
core.setFailed(`Failed to publish the build: ${err}`)

flat-manager/index.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@ class Configuration {
1010
this.endOfLifeRebase = core.getInput('end-of-life-rebase')
1111
// FIXME: get this from the outputs of the flatpak-builder action
1212
this.localRepoName = 'repo'
13+
// Verbosity
14+
this.verbose = core.getBooleanInput('verbose') || false
1315
}
1416
}
1517

1618
const run = (config) => {
17-
exec.exec('flatpak', [
19+
const args = [
1820
'build-update-repo',
1921
'--generate-static-deltas',
2022
config.localRepoName
21-
])
23+
]
24+
if (config.verbose) {
25+
args.push('-vv', '--ostree-verbose')
26+
}
27+
exec.exec('flatpak', args)
2228
.then(async () => {
2329
let buildId = ''
2430
let args = [
@@ -44,6 +50,10 @@ const run = (config) => {
4450
config.repository
4551
])
4652

53+
if (config.verbose) {
54+
args.push('--verbose')
55+
}
56+
4757
const exitCode = await exec.exec('flat-manager-client', args, {
4858
listeners: {
4959
stdout: (data) => {
@@ -57,7 +67,7 @@ const run = (config) => {
5767
return buildId
5868
})
5969
.then(async (buildId) => {
60-
await exec.exec('flat-manager-client', [
70+
const args = [
6171
'--token',
6272
config.token,
6373
'push',
@@ -66,16 +76,25 @@ const run = (config) => {
6676
'--wait',
6777
buildId,
6878
config.localRepoName
69-
])
79+
]
80+
if (config.verbose) {
81+
args.push('--verbose')
82+
}
83+
await exec.exec('flat-manager-client', args)
7084
return buildId
7185
})
7286
.then(async (buildId) => {
73-
await exec.exec('flat-manager-client', [
87+
const args = [
7488
'--token',
7589
config.token,
7690
'purge',
7791
buildId
78-
])
92+
]
93+
94+
if (config.verbose) {
95+
args.push('--verbose')
96+
}
97+
await exec.exec('flat-manager-client', args)
7998
})
8099
.catch((err) => {
81100
core.setFailed(`Failed to publish the build: ${err}`)

flatpak-builder/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ inputs:
7373
description: >
7474
The key to sign the package.
7575
required: false
76+
verbose:
77+
description: >
78+
"Enable verbosity"
79+
required: false
80+
default: "false"
7681
runs:
7782
using: "node16"
7883
main: "dist/index.js"

flatpak-builder/dist/index.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class Configuration {
6363
// The flatpak repository name
6464
this.localRepoName = 'repo'
6565
this.branch = 'master'
66+
// Verbosity
67+
this.verbose = core.getBooleanInput('verbose') || false
6668
}
6769

6870
async cacheKey () {
@@ -81,7 +83,7 @@ class Configuration {
8183

8284
/**
8385
* Start a D-Bus session and return the process and the D-Bus address.
84-
*
86+
*
8587
* @returns {Promise}
8688
*/
8789
const startDBusSession = () => {
@@ -103,7 +105,7 @@ const startDBusSession = () => {
103105

104106
/**
105107
* Compute a SHA-256 hash of a file.
106-
*
108+
*
107109
* @param {PathLike} path The file path.
108110
*/
109111
const computeHash = async (path) => {
@@ -172,7 +174,7 @@ const saveManifest = async (manifest, dest) => {
172174

173175
/**
174176
* Modify the manifest to prepare it for tests.
175-
*
177+
*
176178
* Applies the following changes to the original manifest:
177179
* - Add test-args are to enable network & x11 access.
178180
*
@@ -241,6 +243,9 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
241243
if (config.stopAtModule) {
242244
args.push(`--stop-at=${config.stopAtModule}`)
243245
}
246+
if (config.verbose) {
247+
args.push('--verbose')
248+
}
244249
args.push(config.buildDir, manifestPath)
245250

246251
await exec.exec('xvfb-run --auto-servernum flatpak-builder', args)
@@ -256,21 +261,25 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
256261

257262
if (config.buildBundle && !config.stopAtModule) {
258263
core.info('Creating a bundle...')
259-
await exec.exec('flatpak', [
264+
const args = [
260265
'build-bundle',
261266
config.localRepoName,
262267
config.bundle,
263268
`--runtime-repo=${config.repositoryUrl}`,
264269
`--arch=${config.arch}`,
265270
appId,
266271
branch
267-
])
272+
]
273+
if (config.verbose) {
274+
args.push('-vv', '--ostree-verbose')
275+
}
276+
await exec.exec('flatpak', args)
268277
}
269278
}
270279

271280
/**
272281
* Initialize the build
273-
*
282+
*
274283
* Consists of setting up the Flatpak remote if one other than the default is set
275284
* and restoring the cache from the latest build
276285
*
@@ -280,12 +289,16 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
280289
const prepareBuild = async (config) => {
281290
/// If the user has set a different runtime source
282291
if (config.repositoryUrl !== 'https://flathub.org/repo/flathub.flatpakrepo') {
283-
await exec.exec('flatpak', [
292+
const args = [
284293
'remote-add',
285294
'--if-not-exists',
286295
config.repositoryName,
287296
config.repositoryUrl
288-
])
297+
]
298+
if (config.verbose) {
299+
args.push('-vv', '--ostree-verbose')
300+
}
301+
await exec.exec('flatpak', args)
289302
}
290303

291304
// Restore the cache in case caching is enabled

flatpak-builder/index.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class Configuration {
5757
// The flatpak repository name
5858
this.localRepoName = 'repo'
5959
this.branch = 'master'
60+
// Verbosity
61+
this.verbose = core.getBooleanInput('verbose') || false
6062
}
6163

6264
async cacheKey () {
@@ -75,7 +77,7 @@ class Configuration {
7577

7678
/**
7779
* Start a D-Bus session and return the process and the D-Bus address.
78-
*
80+
*
7981
* @returns {Promise}
8082
*/
8183
const startDBusSession = () => {
@@ -97,7 +99,7 @@ const startDBusSession = () => {
9799

98100
/**
99101
* Compute a SHA-256 hash of a file.
100-
*
102+
*
101103
* @param {PathLike} path The file path.
102104
*/
103105
const computeHash = async (path) => {
@@ -166,7 +168,7 @@ const saveManifest = async (manifest, dest) => {
166168

167169
/**
168170
* Modify the manifest to prepare it for tests.
169-
*
171+
*
170172
* Applies the following changes to the original manifest:
171173
* - Add test-args are to enable network & x11 access.
172174
*
@@ -235,6 +237,9 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
235237
if (config.stopAtModule) {
236238
args.push(`--stop-at=${config.stopAtModule}`)
237239
}
240+
if (config.verbose) {
241+
args.push('--verbose')
242+
}
238243
args.push(config.buildDir, manifestPath)
239244

240245
await exec.exec('xvfb-run --auto-servernum flatpak-builder', args)
@@ -250,21 +255,25 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
250255

251256
if (config.buildBundle && !config.stopAtModule) {
252257
core.info('Creating a bundle...')
253-
await exec.exec('flatpak', [
258+
const args = [
254259
'build-bundle',
255260
config.localRepoName,
256261
config.bundle,
257262
`--runtime-repo=${config.repositoryUrl}`,
258263
`--arch=${config.arch}`,
259264
appId,
260265
branch
261-
])
266+
]
267+
if (config.verbose) {
268+
args.push('-vv', '--ostree-verbose')
269+
}
270+
await exec.exec('flatpak', args)
262271
}
263272
}
264273

265274
/**
266275
* Initialize the build
267-
*
276+
*
268277
* Consists of setting up the Flatpak remote if one other than the default is set
269278
* and restoring the cache from the latest build
270279
*
@@ -274,12 +283,16 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
274283
const prepareBuild = async (config) => {
275284
/// If the user has set a different runtime source
276285
if (config.repositoryUrl !== 'https://flathub.org/repo/flathub.flatpakrepo') {
277-
await exec.exec('flatpak', [
286+
const args = [
278287
'remote-add',
279288
'--if-not-exists',
280289
config.repositoryName,
281290
config.repositoryUrl
282-
])
291+
]
292+
if (config.verbose) {
293+
args.push('-vv', '--ostree-verbose')
294+
}
295+
await exec.exec('flatpak', args)
283296
}
284297

285298
// Restore the cache in case caching is enabled

0 commit comments

Comments
 (0)