Skip to content

Commit

Permalink
Add an option to enable verbosity
Browse files Browse the repository at this point in the history
Fixes #93
  • Loading branch information
bilelmoussaoui committed Apr 2, 2023
1 parent 71351d3 commit 843522c
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/flatpak-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
restore-cache: ${{ matrix.restore == 'cache-restored' }}
cache-key: flatpak-builder-${{ github.sha }}-${{ matrix.restore }}
arch: ${{ matrix.arch }}
verbose: true
# TODO: setup a flat-manager before and use it later here
#- uses: ./flat-manager
# with:
Expand All @@ -63,6 +64,7 @@ jobs:
manifest-path: ./flatpak-builder/tests/test-project/org.example.MyApp.yaml
stop-at-module: testproject
cache: false
verbose: true

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

tests:
name: Tests
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
| `arch` | Specifies the CPU architecture to build for | Optional | `x86_64` |
| `mirror-screenshots-url` | Specifies the URL to mirror screenshots | Optional | - |
| `gpg-sign` | The key to sign the package | Optional | - |
| `verbose` | Enable verbosity | Optional | `false` |

#### Building for multiple CPU architectures

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

### Docker Image

Expand Down
5 changes: 5 additions & 0 deletions flat-manager/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ inputs:
description: >
"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."
required: false
verbose:
description: >
"Enable verbosity"
required: false
default: "false"
runs:
using: "node16"
main: "dist/index.js"
31 changes: 25 additions & 6 deletions flat-manager/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4099,15 +4099,21 @@ class Configuration {
this.endOfLifeRebase = core.getInput('end-of-life-rebase')
// FIXME: get this from the outputs of the flatpak-builder action
this.localRepoName = 'repo'
// Verbosity
this.verbose = core.getBooleanInput('verbose') || false
}
}

const run = (config) => {
exec.exec('flatpak', [
const args = [
'build-update-repo',
'--generate-static-deltas',
config.localRepoName
])
]
if (config.verbose) {
args.push('-vv', '--ostree-verbose')
}
exec.exec('flatpak', args)
.then(async () => {
let buildId = ''
let args = [
Expand All @@ -4133,6 +4139,10 @@ const run = (config) => {
config.repository
])

if (config.verbose) {
args.push('--verbose')
}

const exitCode = await exec.exec('flat-manager-client', args, {
listeners: {
stdout: (data) => {
Expand All @@ -4146,7 +4156,7 @@ const run = (config) => {
return buildId
})
.then(async (buildId) => {
await exec.exec('flat-manager-client', [
const args = [
'--token',
config.token,
'push',
Expand All @@ -4155,16 +4165,25 @@ const run = (config) => {
'--wait',
buildId,
config.localRepoName
])
]
if (config.verbose) {
args.push('--verbose')
}
await exec.exec('flat-manager-client', args)
return buildId
})
.then(async (buildId) => {
await exec.exec('flat-manager-client', [
const args = [
'--token',
config.token,
'purge',
buildId
])
]

if (config.verbose) {
args.push('--verbose')
}
await exec.exec('flat-manager-client', args)
})
.catch((err) => {
core.setFailed(`Failed to publish the build: ${err}`)
Expand Down
31 changes: 25 additions & 6 deletions flat-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ class Configuration {
this.endOfLifeRebase = core.getInput('end-of-life-rebase')
// FIXME: get this from the outputs of the flatpak-builder action
this.localRepoName = 'repo'
// Verbosity
this.verbose = core.getBooleanInput('verbose') || false
}
}

const run = (config) => {
exec.exec('flatpak', [
const args = [
'build-update-repo',
'--generate-static-deltas',
config.localRepoName
])
]
if (config.verbose) {
args.push('-vv', '--ostree-verbose')
}
exec.exec('flatpak', args)
.then(async () => {
let buildId = ''
let args = [
Expand All @@ -44,6 +50,10 @@ const run = (config) => {
config.repository
])

if (config.verbose) {
args.push('--verbose')
}

const exitCode = await exec.exec('flat-manager-client', args, {
listeners: {
stdout: (data) => {
Expand All @@ -57,7 +67,7 @@ const run = (config) => {
return buildId
})
.then(async (buildId) => {
await exec.exec('flat-manager-client', [
const args = [
'--token',
config.token,
'push',
Expand All @@ -66,16 +76,25 @@ const run = (config) => {
'--wait',
buildId,
config.localRepoName
])
]
if (config.verbose) {
args.push('--verbose')
}
await exec.exec('flat-manager-client', args)
return buildId
})
.then(async (buildId) => {
await exec.exec('flat-manager-client', [
const args = [
'--token',
config.token,
'purge',
buildId
])
]

if (config.verbose) {
args.push('--verbose')
}
await exec.exec('flat-manager-client', args)
})
.catch((err) => {
core.setFailed(`Failed to publish the build: ${err}`)
Expand Down
5 changes: 5 additions & 0 deletions flatpak-builder/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ inputs:
description: >
The key to sign the package.
required: false
verbose:
description: >
"Enable verbosity"
required: false
default: "false"
runs:
using: "node16"
main: "dist/index.js"
29 changes: 21 additions & 8 deletions flatpak-builder/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class Configuration {
// The flatpak repository name
this.localRepoName = 'repo'
this.branch = 'master'
// Verbosity
this.verbose = core.getBooleanInput('verbose') || false
}

async cacheKey () {
Expand All @@ -81,7 +83,7 @@ class Configuration {

/**
* Start a D-Bus session and return the process and the D-Bus address.
*
*
* @returns {Promise}
*/
const startDBusSession = () => {
Expand All @@ -103,7 +105,7 @@ const startDBusSession = () => {

/**
* Compute a SHA-256 hash of a file.
*
*
* @param {PathLike} path The file path.
*/
const computeHash = async (path) => {
Expand Down Expand Up @@ -172,7 +174,7 @@ const saveManifest = async (manifest, dest) => {

/**
* Modify the manifest to prepare it for tests.
*
*
* Applies the following changes to the original manifest:
* - Add test-args are to enable network & x11 access.
*
Expand Down Expand Up @@ -241,6 +243,9 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
if (config.stopAtModule) {
args.push(`--stop-at=${config.stopAtModule}`)
}
if (config.verbose) {
args.push('--verbose')
}
args.push(config.buildDir, manifestPath)

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

if (config.buildBundle && !config.stopAtModule) {
core.info('Creating a bundle...')
await exec.exec('flatpak', [
const args = [
'build-bundle',
config.localRepoName,
config.bundle,
`--runtime-repo=${config.repositoryUrl}`,
`--arch=${config.arch}`,
appId,
branch
])
]
if (config.verbose) {
args.push('-vv', '--ostree-verbose')
}
await exec.exec('flatpak', args)
}
}

/**
* Initialize the build
*
*
* Consists of setting up the Flatpak remote if one other than the default is set
* and restoring the cache from the latest build
*
Expand All @@ -280,12 +289,16 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
const prepareBuild = async (config) => {
/// If the user has set a different runtime source
if (config.repositoryUrl !== 'https://flathub.org/repo/flathub.flatpakrepo') {
await exec.exec('flatpak', [
const args = [
'remote-add',
'--if-not-exists',
config.repositoryName,
config.repositoryUrl
])
]
if (config.verbose) {
args.push('-vv', '--ostree-verbose')
}
await exec.exec('flatpak', args)
}

// Restore the cache in case caching is enabled
Expand Down
29 changes: 21 additions & 8 deletions flatpak-builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Configuration {
// The flatpak repository name
this.localRepoName = 'repo'
this.branch = 'master'
// Verbosity
this.verbose = core.getBooleanInput('verbose') || false
}

async cacheKey () {
Expand All @@ -75,7 +77,7 @@ class Configuration {

/**
* Start a D-Bus session and return the process and the D-Bus address.
*
*
* @returns {Promise}
*/
const startDBusSession = () => {
Expand All @@ -97,7 +99,7 @@ const startDBusSession = () => {

/**
* Compute a SHA-256 hash of a file.
*
*
* @param {PathLike} path The file path.
*/
const computeHash = async (path) => {
Expand Down Expand Up @@ -166,7 +168,7 @@ const saveManifest = async (manifest, dest) => {

/**
* Modify the manifest to prepare it for tests.
*
*
* Applies the following changes to the original manifest:
* - Add test-args are to enable network & x11 access.
*
Expand Down Expand Up @@ -235,6 +237,9 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
if (config.stopAtModule) {
args.push(`--stop-at=${config.stopAtModule}`)
}
if (config.verbose) {
args.push('--verbose')
}
args.push(config.buildDir, manifestPath)

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

if (config.buildBundle && !config.stopAtModule) {
core.info('Creating a bundle...')
await exec.exec('flatpak', [
const args = [
'build-bundle',
config.localRepoName,
config.bundle,
`--runtime-repo=${config.repositoryUrl}`,
`--arch=${config.arch}`,
appId,
branch
])
]
if (config.verbose) {
args.push('-vv', '--ostree-verbose')
}
await exec.exec('flatpak', args)
}
}

/**
* Initialize the build
*
*
* Consists of setting up the Flatpak remote if one other than the default is set
* and restoring the cache from the latest build
*
Expand All @@ -274,12 +283,16 @@ const build = async (manifest, manifestPath, cacheHitKey, config) => {
const prepareBuild = async (config) => {
/// If the user has set a different runtime source
if (config.repositoryUrl !== 'https://flathub.org/repo/flathub.flatpakrepo') {
await exec.exec('flatpak', [
const args = [
'remote-add',
'--if-not-exists',
config.repositoryName,
config.repositoryUrl
])
]
if (config.verbose) {
args.push('-vv', '--ostree-verbose')
}
await exec.exec('flatpak', args)
}

// Restore the cache in case caching is enabled
Expand Down

0 comments on commit 843522c

Please sign in to comment.