55 lines
2.6 KiB
TypeScript
55 lines
2.6 KiB
TypeScript
/**
|
|
* The release APK is signed in Custos and nowhere else (fabrica-release.md F4): the arguments
|
|
* name the one key, the exact repository and a tag, and the script never falls back to another
|
|
* custos-sign or another Custos.
|
|
*/
|
|
import { readFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { APK_KEY, custosSign, signArgs, signedApkName, UNSIGNED_APK } from '../src/sign-apk.js';
|
|
|
|
const COMMIT = 'a'.repeat(40);
|
|
const pkg = JSON.parse(readFileSync(join(fileURLToPath(new URL('..', import.meta.url)), 'package.json'), 'utf8')) as { scripts: Record<string, string> };
|
|
|
|
describe('signArgs', () => {
|
|
it('asks for rosea-android, scoped to mnovak/Rosea, the release pipeline and a tag', () => {
|
|
const args = signArgs({ version: '0.1.0', commit: COMMIT, unsigned: 'in.apk', out: 'out.apk' });
|
|
expect(args).toEqual([
|
|
'apk', 'in.apk', '--out', 'out.apk', '--key', 'rosea-android', '--repo', 'mnovak/Rosea', '--pipeline', 'release',
|
|
'--commit', COMMIT, '--trigger', 'tag', '--run', 'rosea-v0.1.0', '--version', '0.1.0', '--step', 'apk'
|
|
]);
|
|
expect(APK_KEY).toBe('rosea-android');
|
|
});
|
|
|
|
it('refuses a version or a commit that is not one', () => {
|
|
expect(() => signArgs({ version: 'v0.1.0', commit: COMMIT, unsigned: 'a', out: 'b' })).toThrow(/not a version/);
|
|
expect(() => signArgs({ version: '0.1.0', commit: 'HEAD', unsigned: 'a', out: 'b' })).toThrow(/not a commit/);
|
|
});
|
|
|
|
it('names the published APK by app, version and ABI', () => {
|
|
expect(signedApkName('0.1.0')).toBe('rosea-domi-0.1.0-arm64.apk');
|
|
});
|
|
|
|
it('signs the release build that android.ts verified, never the debug one', () => {
|
|
expect(UNSIGNED_APK).toContain('/release/');
|
|
expect(pkg.scripts['build:android-release']).toContain(`verify src-tauri/${UNSIGNED_APK}`);
|
|
expect(pkg.scripts['build:android-release']).not.toContain('--debug');
|
|
});
|
|
});
|
|
|
|
describe('custosSign', () => {
|
|
it('runs the custos-sign CUSTOS_SIGN_EXE names, else the one on PATH', () => {
|
|
expect(custosSign({ CUSTOS_SIGN_EXE: 'F:\Apps\Custos\custos-sign.exe' }, () => true)).toBe('F:\Apps\Custos\custos-sign.exe');
|
|
expect(custosSign({}, () => true)).toBe('custos-sign.exe');
|
|
});
|
|
|
|
it('refuses a named custos-sign that is not there, rather than another one', () => {
|
|
expect(() => custosSign({ CUSTOS_SIGN_EXE: 'X:\nowhere.exe' }, () => false)).toThrow(/not there/);
|
|
});
|
|
|
|
it('refuses another Custos (CUSTOS_PIPE)', () => {
|
|
expect(() => custosSign({ CUSTOS_PIPE: '\\.\pipe\test' }, () => true)).toThrow(/CUSTOS_PIPE/);
|
|
});
|
|
});
|