Skip to content

Commit

Permalink
ci: clean dev artifact before retrieving ci build ones + clean package
Browse files Browse the repository at this point in the history
  • Loading branch information
b-ma committed Jan 6, 2025
1 parent abade6e commit c95813c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
7 changes: 4 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
.editorconfig
.env
.gitmodules
.eslintrc

build.rs
Cargo.*
Cross.toml
NOTES.md
dummy.mjs
all-check.sh
all-checks.sh
run-wpt.sh

.scripts
examples
Expand All @@ -22,5 +25,3 @@ issues

*.tgz
*.bak


19 changes: 8 additions & 11 deletions .scripts/move-artifact.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import fs from 'node:fs';
import path from 'node:path';

import {
destReleaseFile,
destDebugFile,
deleteDevArtifacts,
} from './utils/dev-artifacts-helpers.mjs';

const { platform } = process;
const profile = process.argv.includes('--release') ? 'release' : 'debug';

const pkg = fs.readFileSync(path.join('package.json'));
const pkg = fs.readFileSync('package.json');
const PROJECT_NAME = JSON.parse(pkg).name;
const CARGO_BUILD_NAME = PROJECT_NAME.replace(/-/g, '_');

Expand All @@ -26,16 +32,7 @@ switch (platform) {
break;
}

const destReleaseFile = `${PROJECT_NAME}.build-release.node`;
const destDebugFile = `${PROJECT_NAME}.build-debug.node`;

if (fs.existsSync(destReleaseFile)) {
fs.rmSync(destReleaseFile, { force: true });
}

if (fs.existsSync(destDebugFile)) {
fs.rmSync(destDebugFile, { force: true });
}
deleteDevArtifacts();

let srcFile = path.join('target', profile, `${buildPrefix}${CARGO_BUILD_NAME}${buildSuffix}`);
let destFile = profile === 'release' ? destReleaseFile : destDebugFile;
Expand Down
17 changes: 12 additions & 5 deletions .scripts/retrieve-artifacts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ import { Octokit } from 'octokit';
import fs from 'node:fs';
import { execSync } from 'node:child_process';

import { deleteDevArtifacts } from './utils/dev-artifacts-helpers.mjs';

// --------------------------------------------------------------
console.log('');
console.log(`> clean development workspace`);
// --------------------------------------------------------------
deleteDevArtifacts();

// --------------------------------------------------------------
console.log('');
console.log(`> get ${workflowName} workflow id`);
// --------------------------------------------------------------
dotenv.config({ debug: false });

const owner = process.env.REPO_OWNER;
Expand All @@ -27,11 +39,6 @@ function checkResponse(res) {
}
}

// --------------------------------------------------------------
console.log('');
console.log(`> get ${workflowName} workflow id`);
// --------------------------------------------------------------

res = await octokit.request(`GET /repos/${owner}/${repo}/actions/workflows`);
checkResponse(res)

Expand Down
17 changes: 17 additions & 0 deletions .scripts/utils/dev-artifacts-helpers.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import fs from 'node:fs';

const pkg = fs.readFileSync('package.json');
const PROJECT_NAME = JSON.parse(pkg).name;

export const destReleaseFile = `${PROJECT_NAME}.build-release.node`;
export const destDebugFile = `${PROJECT_NAME}.build-debug.node`;

export function deleteDevArtifacts() {
if (fs.existsSync(destReleaseFile)) {
fs.rmSync(destReleaseFile, { force: true });
}

if (fs.existsSync(destDebugFile)) {
fs.rmSync(destDebugFile, { force: true });
}
}

0 comments on commit c95813c

Please sign in to comment.