-
Notifications
You must be signed in to change notification settings - Fork 1
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 #7 from pkl-community/jg-e2e-first
Add first e2e test
- Loading branch information
Showing
21 changed files
with
4,503 additions
and
1,197 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,77 @@ | ||
name: test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
pkl-unit: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
pklVersion: ["0.25.0", "0.25.1"] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Install pkl binary | ||
- name: Create /tmp/bin and add to PATH | ||
run: | | ||
mkdir -p "{{ runner.temp }}/bin" && \ | ||
echo "{{ runner.temp }}/bin" >> "$GITHUB_PATH" | ||
- name: Fetch Pkl binary from GitHub release | ||
uses: dsaltares/fetch-gh-release-asset@master | ||
with: | ||
repo: apple/pkl | ||
version: tags/${{ matrix.pklVersion }} | ||
file: pkl-linux-amd64 | ||
target: "{{ runner.temp }}/bin/pkl" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Make pkl binary executable | ||
run: chmod +x "{{ runner.temp }}/bin/pkl" | ||
|
||
- name: Run tests | ||
run: | | ||
tests=$(find . -name '*.test.pkl') | ||
pkl test $tests | ||
e2e: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18, 20] | ||
pklVersion: ["0.25.0", "0.25.1"] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: npm | ||
|
||
# Install pkl binary | ||
- name: Create /tmp/bin and add to PATH | ||
run: | | ||
mkdir -p "{{ runner.temp }}/bin" && \ | ||
echo "{{ runner.temp }}/bin" >> "$GITHUB_PATH" | ||
- name: Fetch Pkl binary from GitHub release | ||
uses: dsaltares/fetch-gh-release-asset@master | ||
with: | ||
repo: apple/pkl | ||
version: tags/${{ matrix.pklVersion }} | ||
file: pkl-linux-amd64 | ||
target: "{{ runner.temp }}/bin/pkl" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Make pkl binary executable | ||
run: chmod +x "{{ runner.temp }}/bin/pkl" | ||
|
||
- run: npm install | ||
- run: npm run test:e2e |
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,4 +1,4 @@ | ||
#!/usr/bin/env tsx | ||
import pklGenTypescript from "../pkl-gen-typescript/main"; | ||
|
||
pklGenTypescript(); | ||
pklGenTypescript(process.argv.slice(2)); |
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,4 @@ | ||
amends "schema.pkl" | ||
|
||
addr = "localhost" | ||
port = 3000 |
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,3 @@ | ||
amends "schema.pkl" | ||
|
||
addr = "localhost" |
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,4 @@ | ||
amends "schema.pkl" | ||
|
||
addr = "localhost" | ||
port = 3000000000000 |
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,33 @@ | ||
import { describe, expect, it } from "@jest/globals"; | ||
|
||
import pklGenTypescript from "../../pkl-gen-typescript/main"; | ||
import { join } from "path"; | ||
|
||
describe("E2E of config with only primitive values", () => { | ||
it("can generate TypeScript sources and load valid values", async () => { | ||
await pklGenTypescript([join(__dirname, "schema.pkl")]); | ||
const configPkl = await import(join(__dirname, "../../.out/schema.pkl.ts")); | ||
const config = await configPkl.loadFromPath(join(__dirname, "correct.pkl")); | ||
expect(config).toStrictEqual({ | ||
addr: "localhost", | ||
port: 3000, | ||
}); | ||
}); | ||
|
||
it.each([ | ||
["missing a required property", "missingRequired.pkl"], | ||
["property is of the wrong type", "wrongType.pkl"], | ||
["property fails validation constraint", "outOfBounds.pkl"], | ||
])( | ||
"can generate TypeScript sources but error on evaluating invalid values: %s", | ||
async (_, fileBase) => { | ||
await pklGenTypescript([join(__dirname, "schema.pkl")]); | ||
const configPkl = await import( | ||
join(__dirname, "../../.out/schema.pkl.ts") | ||
); | ||
await expect( | ||
configPkl.loadFromPath(join(__dirname, `${fileBase}.pkl`)) | ||
).rejects.toThrowError(); | ||
} | ||
); | ||
}); |
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,2 @@ | ||
addr: String | ||
port: Int16 |
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,4 @@ | ||
amends "schema.pkl" | ||
|
||
addr = "localhost" | ||
port = "3000" |
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,8 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
moduleNameMapper: { | ||
"^@pkl-community/pkl-typescript$": "<rootDir>/src", | ||
}, | ||
}; |
Oops, something went wrong.