Skip to content
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

chore: test natively on Windows #426

Merged
merged 7 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ jobs:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: Vampire/setup-wsl@v2
if: ${{ matrix.os == 'windows-latest' }}
with:
distribution: Alpine

- uses: actions/checkout@v3
with:
path: ./
Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,9 @@ Output parameters:

## Windows

Windows is currently supported via Windows Subsystem for Linux (WSL). It is
required to set up a WSL distribution prior to invoking the `sbom-action`, for
example, you can add the small Alpine image:

```yaml
- uses: Vampire/setup-wsl@v2
with:
distribution: Alpine
```
This action is tested on Windows, and should work natively on Windows hosts
without WSL. (Note that it previously required WSL, but should now be run
natively on Windows.)

## Diagnostics

Expand Down
15 changes: 7 additions & 8 deletions dist/attachReleaseAssets/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions dist/downloadSyft/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions dist/runSyftAction/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions src/github/Executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@ export async function execute(
args: string[],
options?: exec.ExecOptions
) {
if (process.platform === "win32") {
return await exec.exec(
"wsl",
[mapToWSLPath(cmd), ...args.map(mapToWSLPath)],
options
);
} else {
return exec.exec(cmd, args, options);
}
return exec.exec(cmd, args, options);
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/github/SyftGithubAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,18 @@ export async function downloadSyft(): Promise<string> {

await execute("sh", [installPath, "-d", "-b", syftBinaryPath, version]);

return `${syftBinaryPath}/${name}`;
const installedPath = path.join(`${syftBinaryPath}`, `${name}`);
kzantow marked this conversation as resolved.
Show resolved Hide resolved
if (process.platform === "win32") {
return `${installedPath}.exe`;
}
return installedPath;
}

/**
* Gets the Syft command to run via exec
*/
export async function getSyftCommand(): Promise<string> {
const name = SYFT_BINARY_NAME;
const name = SYFT_BINARY_NAME + (process.platform == "win32" ? ".exe" : "");
kzantow marked this conversation as resolved.
Show resolved Hide resolved
const version = SYFT_VERSION;

const sourceSyft = await downloadSyftFromZip(version);
Expand Down