Skip to content

CI: don't run npm pack twice #6923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,8 @@ jobs:
- name: Move artifacts
run: ./scripts/moveArtifacts.sh

- name: Check artifact list
run: node ./scripts/makeArtifactList.js -check

- name: npm pack (rescript)
run: npm pack
- name: npm pack (rescript) + check artifact list
run: node ./scripts/npmPack.js

- name: Copy JS files to stdlib package
run: mkdir -p packages/std/lib && cp -R lib/es6 lib/js packages/std/lib
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ lib: build node_modules/.bin/semver
./scripts/prebuilt.js

artifacts: lib
./scripts/makeArtifactList.js
./scripts/npmPack.js -updateArtifactList

# Builds the core playground bundle (without the relevant cmijs files for the runtime)
playground:
Expand Down
24 changes: 15 additions & 9 deletions scripts/makeArtifactList.js → scripts/npmPack.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
// @ts-check

// This script creates the list of the files that go into the rescript npm package.
//
Expand All @@ -13,28 +14,33 @@ const { spawnSync, execSync } = require("child_process");
const path = require("path");
const fs = require("fs");

const isCheckMode = process.argv.includes("-check");
const mode = process.argv.includes("-updateArtifactList")
? "updateArtifactList"
: "package";

const rootPath = path.join(__dirname, "..");
const fileListPath = path.join(rootPath, "packages", "artifacts.txt");

const output = spawnSync(`npm pack --dry-run --json`, {
cwd: rootPath,
encoding: "utf8",
shell: true,
}).stdout;
const output = spawnSync(
"npm pack --json" + (mode === "updateArtifactList" ? " --dry-run" : ""),
{
cwd: rootPath,
encoding: "utf8",
shell: true,
},
).stdout;

const [{ files }] = JSON.parse(output);
let filePaths = files.map(file => file.path);
let filePaths = files.map((/** @type {{ path: string; }} */ file) => file.path);

if (!isCheckMode) {
if (mode === "updateArtifactList") {
filePaths = Array.from(new Set(filePaths.concat(getFilesAddedByCI())));
}

filePaths.sort();
fs.writeFileSync(fileListPath, filePaths.join("\n"));

if (isCheckMode) {
if (mode === "package") {
execSync(`git diff --exit-code ${fileListPath}`, { stdio: "inherit" });
}

Expand Down