-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1074 from polywrap/go-codegen
Golang Wrap Support
- Loading branch information
Showing
120 changed files
with
6,530 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: CI-Golang | ||
|
||
on: | ||
push: | ||
branches: | ||
- origin | ||
- origin-dev | ||
pull_request: | ||
|
||
jobs: | ||
Test-Cli: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Read .nvmrc | ||
run: echo ::set-output name=NVMRC::$(cat .nvmrc) | ||
id: nvm | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@master | ||
with: | ||
node-version: '${{ steps.nvm.outputs.NVMRC }}' | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Install dependencies | ||
run: yarn install --nonInteractive --frozen-lockfile --prefer-offline | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Test | ||
run: yarn test:golang | ||
working-directory: ./packages/cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
collectCoverage: true, | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
globals: { | ||
"ts-jest": { | ||
diagnostics: false | ||
}, | ||
}, | ||
modulePathIgnorePatterns: [ | ||
"<rootDir>/build", | ||
"<rootDir>/src/__tests__/project/.polywrap" | ||
], | ||
testPathIgnorePatterns: [ | ||
"<rootDir>/src/__tests__/project/.polywrap" | ||
], | ||
transformIgnorePatterns: [ | ||
"<rootDir>/src/__tests__/project/.polywrap" | ||
], | ||
setupFilesAfterEnv: ["./jest.setup.js"], | ||
testMatch: ["**/build-go.spec.ts"] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { polywrapCli } from "./utils"; | ||
import { Commands } from "@polywrap/cli-js"; | ||
import { GetPathToCliTestFiles } from "@polywrap/test-cases"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
jest.setTimeout(1500000); | ||
|
||
describe("e2e tests for build command", () => { | ||
const testCaseRoot = path.join(GetPathToCliTestFiles(), "build-cmd/wasm/golang"); | ||
const testCases = fs | ||
.readdirSync(testCaseRoot, { withFileTypes: true }) | ||
.filter((dirent) => dirent.isDirectory()) | ||
.map((dirent) => dirent.name); | ||
|
||
const getTestCaseDir = (index: number) => | ||
path.join(testCaseRoot, testCases[index]); | ||
|
||
describe("Image strategy", () => { | ||
it("Builds for go", async () => { | ||
const { exitCode: code, stdout: output } = await Commands.build({ | ||
strategy: "image", | ||
verbose: true | ||
}, { | ||
cwd: getTestCaseDir(0), | ||
cli: polywrapCli, | ||
}); | ||
const buildDir = `./build`; | ||
|
||
expect(code).toEqual(0); | ||
expect(output).toContain(`Artifacts written to ${buildDir}`); | ||
expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`); | ||
}); | ||
}) | ||
|
||
// NOTE: Skipped because CI needs system prequisites: golang | ||
describe.skip("Local strategy", () => { | ||
it("Builds for rust", async () => { | ||
const { exitCode: code, stdout: output } = await Commands.build({ | ||
strategy: "local", | ||
verbose: true | ||
}, { | ||
cwd: getTestCaseDir(0), | ||
cli: polywrapCli, | ||
}); | ||
|
||
const buildDir = `./build`; | ||
|
||
expect(code).toEqual(0); | ||
expect(output).toContain(`Artifacts written to ${buildDir}`); | ||
expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`); | ||
}); | ||
}) | ||
|
||
describe("VM strategy", () => { | ||
it("Builds for go", async () => { | ||
const { exitCode: code, stdout: output } = await Commands.build({ | ||
strategy: "vm", | ||
verbose: true | ||
}, { | ||
cwd: getTestCaseDir(0), | ||
cli: polywrapCli, | ||
}); | ||
|
||
const buildDir = `./build`; | ||
|
||
expect(code).toEqual(0); | ||
expect(output).toContain(`Artifacts written to ${buildDir}`); | ||
expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`); | ||
}); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { PolywrapManifestLanguage } from "../"; | ||
|
||
import { PolywrapManifest } from "@polywrap/polywrap-manifest-types-js"; | ||
import path from "path"; | ||
import fs from "fs"; | ||
|
||
export interface BuildOverrides { | ||
validateManifest?: (manifest: PolywrapManifest) => Promise<void>; | ||
|
||
sourcesSubDirectory?: string; | ||
} | ||
|
||
export async function tryGetBuildOverrides( | ||
language: PolywrapManifestLanguage | ||
): Promise<BuildOverrides | undefined> { | ||
const modulePath = path.join( | ||
__dirname, | ||
"..", | ||
"defaults", | ||
"language-overrides", | ||
language, | ||
"index.js" | ||
); | ||
let overrides: BuildOverrides | undefined; | ||
|
||
if (fs.existsSync(modulePath)) { | ||
const module = await import(modulePath); | ||
|
||
// Get any build overrides for the given build-image | ||
if (module.getBuildOverrides) { | ||
overrides = module.getBuildOverrides() as BuildOverrides; | ||
} | ||
} | ||
|
||
return Promise.resolve(overrides); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./BuildOverrides"; | ||
export * from "./BuildStrategy"; | ||
export * from "./strategies"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.