Compare commits

...

7 Commits

Author SHA1 Message Date
CrazyMax
8672cc70f4 Merge pull request #489 from trim21/get-commit-data
Some checks failed
publish / publish (push) Has been cancelled
feat: add method to get commit date from git
2024-11-13 13:39:55 +01:00
Trim21
31cb9c3bde feat: add method to get commit date from git
Signed-off-by: Trim21 <trim21.me@gmail.com>
2024-11-13 20:11:46 +08:00
CrazyMax
781874f7fa Merge pull request #486 from vvoland/docker-install-rootless2
docker/install: Fix rootless install, make teardown also cleanup the toolDir
2024-11-13 12:04:15 +01:00
Paweł Gronowski
54e0f74a84 docker/install: Stop docker service on Windows
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-08 18:07:31 +01:00
Paweł Gronowski
15a9f92044 docker/install: Copy all rootless-extras files
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-08 17:58:08 +01:00
Paweł Gronowski
0b611e6c46 docker/install: Clean up toolDir in teardown
The `toolDir` is added to `PATH` on install, so make sure the binaries
aren't accessible after a teardown.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-08 17:58:05 +01:00
Paweł Gronowski
4980de30fc test/install: Use separate runDir for each test
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-08 17:58:03 +01:00
4 changed files with 29 additions and 4 deletions

View File

@@ -23,7 +23,7 @@ import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docke
import {Docker} from '../../src/docker/docker';
import {Exec} from '../../src/exec';
const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-'));
const tmpDir = () => fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-'));
describe('install', () => {
const originalEnv = process.env;
@@ -51,7 +51,7 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g
await ensureNoSystemContainerd();
const install = new Install({
source: source,
runDir: tmpDir,
runDir: tmpDir(),
contextName: 'foo',
daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}`
});
@@ -74,7 +74,7 @@ describe('rootless', () => {
await ensureNoSystemContainerd();
const install = new Install({
source: source,
runDir: tmpDir,
runDir: tmpDir(),
contextName: 'foo',
daemonConfig: `{"debug":true}`,
rootless: true

View File

@@ -279,3 +279,10 @@ describe('tag', () => {
});
});
});
describe('getCommitDate', () => {
it('head', async () => {
const date = await Git.commitDate('HEAD');
await expect(date).toBeInstanceOf(Date);
});
});

View File

@@ -170,7 +170,11 @@ export class Install {
if (this.rootless) {
core.info(`Downloading Docker rootless extras ${version} from ${this.source.channel} at download.docker.com`);
const extrasFolder = await this.downloadStaticArchive('docker-rootless-extras', this.source);
fs.copyFileSync(path.join(extrasFolder, 'dockerd-rootless.sh'), path.join(extractFolder, 'dockerd-rootless.sh'));
fs.readdirSync(extrasFolder).forEach(file => {
const src = path.join(extrasFolder, file);
const dest = path.join(extractFolder, file);
fs.copyFileSync(src, dest);
});
}
break;
}
@@ -492,6 +496,13 @@ EOF`,
throw new Error(`Unsupported platform: ${os.platform()}`);
}
}
await core.group(`Cleaning up toolDir`, async () => {
if (!this._toolDir) {
return;
}
fs.rmSync(this._toolDir, {recursive: true, force: true});
});
}
private async tearDownDarwin(): Promise<void> {
@@ -541,6 +552,9 @@ EOF`,
await core.group('Removing Docker context', async () => {
await Docker.exec(['context', 'rm', '-f', this.contextName]);
});
await core.group('Stopping Docker daemon service', async () => {
await Exec.exec('powershell', ['-Command', `Stop-Service -Name docker -Force`]);
});
}
private downloadURL(component: 'docker' | 'docker-rootless-extras', version: string, channel: string): string {

View File

@@ -163,4 +163,8 @@ export class Git {
return res.stdout.trim();
});
}
public static async commitDate(ref: string): Promise<Date> {
return new Date(await Git.exec(['show', '-s', '--format="%ci"', ref]));
}
}