Skip to content

Commit

Permalink
fix(port): cpy_bs doesn't work on arm (#60)
Browse files Browse the repository at this point in the history
* wip: linux/arm in docker on mac-14

* wip: try `custom-macos`

* wip: try inline docker

* wip: try `custom-macos`

* fix: remove unnecessary action

* fix: move platform flags into tests

* refactor: merge new job into matrix

* fix: broken aarch64 ports

* wip: log

* fix: diambiguate platforms in harness

* fix: silly ci bug
  • Loading branch information
Yohe-Am authored May 7, 2024
1 parent 9c5203f commit d46ddd4
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 18 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.git
.vscode
tests/
*.md
26 changes: 14 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ jobs:
matrix:
include:
- os: ubuntu-latest
platform: linux/x86_64
e2eType: "docker"
- os: custom-macos
platform: linux/aarch64
e2eType: "docker"
- os: macos-latest
platform: darwin/x86_64
e2eType: "local"
- os: macos-14
platform: darwin/aarch64
e2eType: "local"
# - os: windows-latest
# e2eType: "local"
Expand All @@ -52,24 +58,20 @@ jobs:
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}

- if: "${{ matrix.os == 'macos-latest' || matrix.os == 'macos-14' }}"
# we need coreutils on max for the `timeout` command
run: brew install fish zsh coreutils
- name: Cache deno dir
if: "${{ matrix.os == 'macos-latest' || matrix.os == 'macos-14' }}"
uses: actions/cache@v4
with:
path: ${{ env.DENO_DIR }}
key: deno-mac-${{ hashFiles('**/deno.lock') }}
key: deno-${{ hashFiles('**/deno.lock') }}
- if: "${{ matrix.e2eType == 'docker' }}"
uses: docker/setup-buildx-action@v3
- if: "${{ matrix.e2eType == 'docker' }}"
uses: actions-hub/docker/cli@master
env:
SKIP_LOGIN: true

- run: deno task test
- if: "${{ matrix.os == 'macos-latest' || matrix.os == 'macos-14' }}"
# we need coreutils on max for the `timeout` command
run: brew install fish zsh coreutils
- env:
DOCKER_PLATFORM: ${{ matrix.platform }}
run: deno task test


test-action:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
gh_action/.*.js
)$
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
rev: 0.28.2
hooks:
- id: check-dependabot
- id: check-github-workflows
Expand Down
1 change: 1 addition & 0 deletions check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { $ } from "./utils/mod.ts";
const files = (await Array.fromAsync(
$.path(import.meta.url).parentOrThrow().expandGlob("**/*.ts", {
exclude: [
"play.ts",
".ghjk/**",
".deno-dir/**",
],
Expand Down
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tasks": {
"test": "GHJK_LOG=debug deno test --parallel --unstable-worker-options --unstable-kv -A tests/*",
"test": "deno test --parallel --unstable-worker-options --unstable-kv -A tests/*",
"cache": "deno cache deps/*",
"check": "deno run -A check.ts"
},
Expand Down
6 changes: 5 additions & 1 deletion ports/cpy_bs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export class Port extends PortBase {
}
const { installVersion, platform } = args;
const arch = platform.arch;
let postfix = "pgo+lto-full";
let os;
switch (platform.os) {
case "windows":
Expand All @@ -157,6 +158,9 @@ export class Port extends PortBase {
// but it breaks python extensions support so we
// must use glibc
os = "unknown-linux-gnu";
if (arch == "aarch64") {
postfix = "lto-full";
}
break;
case "darwin":
os = "apple-darwin";
Expand All @@ -165,7 +169,7 @@ export class Port extends PortBase {
throw new Error(`unsupported: ${platform}`);
}
const urls = [
`https://github.com/${this.repoOwner}/${this.repoName}/releases/download/${tag}/cpython-${installVersion}+${tag}-${arch}-${os}-pgo+lto-full.tar.zst`,
`https://github.com/${this.repoOwner}/${this.repoName}/releases/download/${tag}/cpython-${installVersion}+${tag}-${arch}-${os}-${postfix}.tar.zst`,
];
await Promise.all(
urls.map(dwnUrlOut)
Expand Down
3 changes: 3 additions & 0 deletions ports/meta_cli_ghrel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export class Port extends GithubReleasePort {
default:
throw new Error(`unsupported: ${platform}`);
}
if (platform.os == "linux" && platform.arch == "aarch64") {
throw new Error(`unsupported: ${platform}`);
}
return [
this.releaseArtifactUrl(
installVersion,
Expand Down
2 changes: 2 additions & 0 deletions tests/ports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
InstallConfigFat,
PortsModuleSecureConfig,
} from "../modules/ports/types.ts";
import { testTargetPlatform } from "./utils.ts";

type CustomE2eTestCase = Omit<E2eTestCase, "ePoints" | "tsGhjkfileStr"> & {
ePoint: string;
Expand Down Expand Up @@ -139,6 +140,7 @@ const cases: CustomE2eTestCase[] = [
// executrable
? `which meta && wasmedge --version`
: `meta --version && wasmedge --version`,
ignore: testTargetPlatform == "linux/aarch64",
},
// 77 meg +
{
Expand Down
4 changes: 4 additions & 0 deletions tests/test.Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
.vscode
tests/
*.md
23 changes: 21 additions & 2 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import type {
PortsModuleSecureConfig,
} from "../modules/ports/types.ts";
import type { TaskDefNice } from "../mod.ts";
import { ALL_OS } from "../port.ts";
import { ALL_ARCH } from "../port.ts";

export type E2eTestCase = {
name: string;
Expand All @@ -14,7 +16,24 @@ export type E2eTestCase = {
ePoints: { cmd: string; stdin?: string }[];
};

export const testTargetPlatform = Deno.env.get("DOCKER_PLATFORM") ??
(Deno.build.os + "/" + Deno.build.arch);

if (
!([...ALL_OS] as string[]).includes(testTargetPlatform.split("/")[0]) ||
!([...ALL_ARCH] as string[]).includes(testTargetPlatform.split("/")[1])
) {
throw new Error(`unsupported test platform: ${testTargetPlatform}`);
}

const dockerPlatform = `--platform=${
testTargetPlatform
.replace("x86_64", "amd64")
.replace("aarch64", "arm64")
}`;

const dockerCmd = (Deno.env.get("DOCKER_CMD") ?? "docker").split(/\s/);

const dFileTemplate = await importRaw(import.meta.resolve("./test.Dockerfile"));
const templateStrings = {
addConfig: `#{{CMD_ADD_CONFIG}}`,
Expand Down Expand Up @@ -56,14 +75,14 @@ export async function dockerE2eTest(testCase: E2eTestCase) {
));

await $
.raw`${dockerCmd} buildx build ${
.raw`${dockerCmd} buildx build ${dockerPlatform} ${
Object.entries(env).map(([key, val]) => ["--build-arg", `${key}=${val}`])
} --tag '${tag}' --network=host --output type=docker -f- .`
.env(env)
.stdinText(dFile);

for (const ePoint of ePoints) {
let cmd = $.raw`${dockerCmd} run --rm ${[
let cmd = $.raw`${dockerCmd} run ${dockerPlatform} --rm ${[
/* we want to enable interactivity when piping in */
ePoint.stdin ? "-i " : "",
...Object.entries(env).map(([key, val]) => ["-e", `${key}=${val}`])
Expand Down

0 comments on commit d46ddd4

Please sign in to comment.