Skip to content

Commit 98e182e

Browse files
chrmartiCopilot
andcommitted
Fix rootless Podman tests on hosted runners
Disable the static Podman bundle's single-owner storage mode before Feature builds so APT can use its unprivileged sandbox. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 987bbc7 commit 98e182e

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎src/test/cli.podman.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import * as assert from 'assert';
77
import * as path from 'path';
8+
import { readFile, writeFile } from 'fs/promises';
89
import { shellExec } from './testUtils';
910

1011
const pkg = require('../../package.json');
@@ -18,6 +19,20 @@ describe('Dev Containers CLI using Podman', function () {
1819
before('Install', async () => {
1920
await shellExec(`rm -rf ${tmp}/node_modules`);
2021
await shellExec(`mkdir -p ${tmp}`);
22+
if (process.env.GITHUB_ACTIONS === 'true') {
23+
const storageConfig = path.join(process.env.HOME!, '.config', 'containers', 'storage.conf');
24+
const storageConfigContent = await readFile(storageConfig, 'utf8');
25+
const updatedStorageConfigContent = storageConfigContent.replace(
26+
/^(\s*ignore_chown_errors\s*=\s*)"true"/m,
27+
'$1"false"'
28+
);
29+
if (updatedStorageConfigContent !== storageConfigContent) {
30+
// The hosted runner's Podman bundle enables ownership squashing,
31+
// which prevents APT's unprivileged _apt user from writing during builds.
32+
await shellExec('podman system reset --force');
33+
await writeFile(storageConfig, updatedStorageConfigContent);
34+
}
35+
}
2136
await shellExec(`npm --prefix ${tmp} install devcontainers-cli-${pkg.version}.tgz`);
2237
});
2338

0 commit comments

Comments
 (0)