Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 1 addition & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
"image": "mcr.microsoft.com/devcontainers/go:1-bookworm",
"customizations": {
"vscode": {
"extensions": [
"golang.go",
"GitHub.copilot-chat",
"GitHub.copilot",
"github.vscode-github-actions",
"astro-build.astro-vscode",
"DavidAnson.vscode-markdownlint"
]
"extensions": ["golang.go", "GitHub.copilot-chat", "GitHub.copilot", "github.vscode-github-actions", "astro-build.astro-vscode", "DavidAnson.vscode-markdownlint"]
},
"codespaces": {
"repositories": {
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,13 @@ security-trivy:
test-js: build-js
cd actions/setup/js && npm run test:js -- --no-file-parallelism

# Install JavaScript dependencies
.PHONY: deps-js
deps-js: check-node-version
cd actions/setup/js && npm ci

.PHONY: build-js
build-js:
build-js: deps-js
cd actions/setup/js && npm run typecheck

# Bundle JavaScript files with local requires
Expand Down
19 changes: 16 additions & 3 deletions actions/setup/js/check_membership.test.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect, beforeEach, vi } from "vitest";
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";

describe("check_membership.cjs", () => {
let mockCore;
Expand Down Expand Up @@ -62,14 +62,27 @@ describe("check_membership.cjs", () => {
const utilsPath = path.join(import.meta.dirname, "check_permissions_utils.cjs");
const utilsContent = fs.readFileSync(utilsPath, "utf8");

// Load error helpers module
const errorHelpersPath = path.join(import.meta.dirname, "error_helpers.cjs");
const errorHelpersContent = fs.readFileSync(errorHelpersPath, "utf8");

// Create a mock require function
const mockRequire = modulePath => {
if (modulePath === "./error_helpers.cjs") {
// Execute the error helpers module and return its exports
const errorHelpersFunction = new Function("module", "exports", errorHelpersContent);
const errorHelpersModuleExports = {};
const errorHelpersMockModule = { exports: errorHelpersModuleExports };
errorHelpersFunction(errorHelpersMockModule, errorHelpersModuleExports);
return errorHelpersMockModule.exports;
}
if (modulePath === "./check_permissions_utils.cjs") {
// Execute the utility module and return its exports
const utilsFunction = new Function("core", "github", "context", "process", "module", "exports", utilsContent);
// Need to pass mockRequire to handle error_helpers require
const utilsFunction = new Function("core", "github", "context", "process", "module", "exports", "require", utilsContent);
const moduleExports = {};
const mockModule = { exports: moduleExports };
utilsFunction(mockCore, mockGithub, mockContext, process, mockModule, moduleExports);
utilsFunction(mockCore, mockGithub, mockContext, process, mockModule, moduleExports, mockRequire);
return mockModule.exports;
}
throw new Error(`Module not found: ${modulePath}`);
Expand Down