mirror of
https://github.com/lopsided98/nix-ros-overlay.git
synced 2025-06-12 02:34:50 +03:00
actions: try to make failed builds cache work
This commit is contained in:
parent
315a2ee2c4
commit
4e25747880
2 changed files with 19 additions and 11 deletions
|
@ -80511,7 +80511,6 @@ class BuildGraph {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function main_instantiate(nixFile, rootAttribute, drvDir, system, parallelism = 4) {
|
async function main_instantiate(nixFile, rootAttribute, drvDir, system, parallelism = 4) {
|
||||||
await io.mkdirP(drvDir);
|
|
||||||
const attrs = await listAttrs(nixFile, rootAttribute);
|
const attrs = await listAttrs(nixFile, rootAttribute);
|
||||||
const queue = new PQueue({ concurrency: parallelism });
|
const queue = new PQueue({ concurrency: parallelism });
|
||||||
return await queue.addAll(attrs.map(attr => async () => {
|
return await queue.addAll(attrs.map(attr => async () => {
|
||||||
|
@ -80555,7 +80554,7 @@ async function main_instantiate(nixFile, rootAttribute, drvDir, system, parallel
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
async function build(drvPath, resultDir, cachixCache) {
|
async function build(drvPath, resultDir, cachixCache, cacheDir) {
|
||||||
const cacheKey = "failed-" + external_path_.basename(drvPath, ".drv");
|
const cacheKey = "failed-" + external_path_.basename(drvPath, ".drv");
|
||||||
try {
|
try {
|
||||||
if (await isDrvCached(drvPath)) {
|
if (await isDrvCached(drvPath)) {
|
||||||
|
@ -80573,7 +80572,7 @@ async function build(drvPath, resultDir, cachixCache) {
|
||||||
if (cache.isFeatureAvailable()) {
|
if (cache.isFeatureAvailable()) {
|
||||||
// We don't actually store anything in the cache, just lookup the
|
// We don't actually store anything in the cache, just lookup the
|
||||||
// derivation name
|
// derivation name
|
||||||
if (await cache.restoreCache(["/var/empty"], cacheKey, [], { lookupOnly: true }) !== undefined) {
|
if (await cache.restoreCache([cacheDir], cacheKey, [], { lookupOnly: true }) !== undefined) {
|
||||||
core.debug(`found cached failure: ${drvPath}`);
|
core.debug(`found cached failure: ${drvPath}`);
|
||||||
return {
|
return {
|
||||||
status: 'cached_failure',
|
status: 'cached_failure',
|
||||||
|
@ -80600,7 +80599,7 @@ async function build(drvPath, resultDir, cachixCache) {
|
||||||
if (typeof error === 'string') {
|
if (typeof error === 'string') {
|
||||||
try {
|
try {
|
||||||
if (cache.isFeatureAvailable()) {
|
if (cache.isFeatureAvailable()) {
|
||||||
await cache.saveCache(["/var/empty"], cacheKey);
|
await cache.saveCache([cacheDir], cacheKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -80632,6 +80631,11 @@ async function run() {
|
||||||
const buildDir = "build";
|
const buildDir = "build";
|
||||||
const drvDir = external_path_.join(buildDir, 'drvs');
|
const drvDir = external_path_.join(buildDir, 'drvs');
|
||||||
const resultDir = external_path_.join(buildDir, 'results');
|
const resultDir = external_path_.join(buildDir, 'results');
|
||||||
|
// Empty directory to make GitHub Actions cache happy
|
||||||
|
const cacheDir = external_path_.join(buildDir, 'cache');
|
||||||
|
await io.mkdirP(drvDir);
|
||||||
|
await io.mkdirP(resultDir);
|
||||||
|
await io.mkdirP(cacheDir);
|
||||||
const successes = [];
|
const successes = [];
|
||||||
const cachedSuccesses = [];
|
const cachedSuccesses = [];
|
||||||
const evalFailures = [];
|
const evalFailures = [];
|
||||||
|
@ -80686,7 +80690,7 @@ async function run() {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const r = await build(node.drvPath, resultDir, cachixCache);
|
const r = await build(node.drvPath, resultDir, cachixCache, cacheDir);
|
||||||
if (r.status === 'cached_success' || r.status === 'success') {
|
if (r.status === 'cached_success' || r.status === 'success') {
|
||||||
buildGraph.succeeded(node);
|
buildGraph.succeeded(node);
|
||||||
}
|
}
|
||||||
|
|
16
.github/actions/nix-ros-build-action/src/main.ts
vendored
16
.github/actions/nix-ros-build-action/src/main.ts
vendored
|
@ -134,7 +134,6 @@ type EvalResult = EvalSuccess | EvalFailure | EvalError;
|
||||||
|
|
||||||
|
|
||||||
async function instantiate(nixFile: string, rootAttribute: string, drvDir: string, system?: string, parallelism = 4): Promise<EvalResult[]> {
|
async function instantiate(nixFile: string, rootAttribute: string, drvDir: string, system?: string, parallelism = 4): Promise<EvalResult[]> {
|
||||||
await io.mkdirP(drvDir)
|
|
||||||
const attrs = await nix.listAttrs(nixFile, rootAttribute)
|
const attrs = await nix.listAttrs(nixFile, rootAttribute)
|
||||||
|
|
||||||
const queue = new PQueue({ concurrency: parallelism })
|
const queue = new PQueue({ concurrency: parallelism })
|
||||||
|
@ -211,7 +210,7 @@ interface BuildError {
|
||||||
|
|
||||||
type BuildResult = BuildSuccess | BuildCachedSuccess | BuildFailure | BuildCachedFailure | BuildError;
|
type BuildResult = BuildSuccess | BuildCachedSuccess | BuildFailure | BuildCachedFailure | BuildError;
|
||||||
|
|
||||||
async function build(drvPath: string, resultDir: string, cachixCache: string): Promise<BuildResult> {
|
async function build(drvPath: string, resultDir: string, cachixCache: string, cacheDir: string): Promise<BuildResult> {
|
||||||
const cacheKey = "failed-" + path.basename(drvPath, ".drv");
|
const cacheKey = "failed-" + path.basename(drvPath, ".drv");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -230,7 +229,7 @@ async function build(drvPath: string, resultDir: string, cachixCache: string): P
|
||||||
if (cache.isFeatureAvailable()) {
|
if (cache.isFeatureAvailable()) {
|
||||||
// We don't actually store anything in the cache, just lookup the
|
// We don't actually store anything in the cache, just lookup the
|
||||||
// derivation name
|
// derivation name
|
||||||
if (await cache.restoreCache(["/var/empty"], cacheKey, [], { lookupOnly: true }) !== undefined) {
|
if (await cache.restoreCache([cacheDir], cacheKey, [], { lookupOnly: true }) !== undefined) {
|
||||||
core.debug(`found cached failure: ${drvPath}`)
|
core.debug(`found cached failure: ${drvPath}`)
|
||||||
return {
|
return {
|
||||||
status: 'cached_failure',
|
status: 'cached_failure',
|
||||||
|
@ -259,7 +258,7 @@ async function build(drvPath: string, resultDir: string, cachixCache: string): P
|
||||||
if (typeof error === 'string') {
|
if (typeof error === 'string') {
|
||||||
try {
|
try {
|
||||||
if (cache.isFeatureAvailable()) {
|
if (cache.isFeatureAvailable()) {
|
||||||
await cache.saveCache(["/var/empty"], cacheKey)
|
await cache.saveCache([cacheDir], cacheKey)
|
||||||
}
|
}
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
core.warning(`failed to cache failed build for ${drvPath}: ${e}`)
|
core.warning(`failed to cache failed build for ${drvPath}: ${e}`)
|
||||||
|
@ -325,6 +324,12 @@ async function run() {
|
||||||
const buildDir = "build"
|
const buildDir = "build"
|
||||||
const drvDir = path.join(buildDir, 'drvs')
|
const drvDir = path.join(buildDir, 'drvs')
|
||||||
const resultDir = path.join(buildDir, 'results')
|
const resultDir = path.join(buildDir, 'results')
|
||||||
|
// Empty directory to make GitHub Actions cache happy
|
||||||
|
const cacheDir = path.join(buildDir, 'cache')
|
||||||
|
|
||||||
|
await io.mkdirP(drvDir)
|
||||||
|
await io.mkdirP(resultDir)
|
||||||
|
await io.mkdirP(cacheDir)
|
||||||
|
|
||||||
const successes: SuccessResult[] = []
|
const successes: SuccessResult[] = []
|
||||||
const cachedSuccesses: CachedSuccessResult[] = []
|
const cachedSuccesses: CachedSuccessResult[] = []
|
||||||
|
@ -350,7 +355,6 @@ async function run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create graph of references used to order the builds
|
// Create graph of references used to order the builds
|
||||||
const buildGraph = new BuildGraph();
|
const buildGraph = new BuildGraph();
|
||||||
for (const [drvPath, drv] of derivations) {
|
for (const [drvPath, drv] of derivations) {
|
||||||
|
@ -389,7 +393,7 @@ async function run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const r = await build(node.drvPath, resultDir, cachixCache)
|
const r = await build(node.drvPath, resultDir, cachixCache, cacheDir)
|
||||||
|
|
||||||
if (r.status === 'cached_success' || r.status === 'success') {
|
if (r.status === 'cached_success' || r.status === 'success') {
|
||||||
buildGraph.succeeded(node)
|
buildGraph.succeeded(node)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue