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

Implement release CI #1030

Merged
merged 16 commits into from
Mar 19, 2022
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
60 changes: 0 additions & 60 deletions .github/workflows/fix.yaml

This file was deleted.

95 changes: 95 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# .github/release.yml

name: release
on:
push:
branches:
- "master"
# - "ci"
# paths:
# - package.json

jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true

- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: 16

- name: Install dependencies
run: |
yarn install

- name: Build, lint, format
run: |
yarn clean
yarn lint:fix
yarn prettier:fix
yarn build

- name: Commit and push
run: |
git add .
git config --global user.name 'ZodBot'
git config --global user.email '[email protected]'
git commit -am "chore: Format, lint, build Deno"
git push

- id: publish
name: Publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
dry-run: false

- name: Post-publish
if: steps.publish.outputs.type != 'none'
run: |
echo "Published ${{ steps.publish.outputs.type }} version: ${{ steps.publish.outputs.version }}"

- name: Publish skipped
if: steps.publish.outputs.type == 'none'
run: |
echo "Version in package.json has not changed. Skipping."
exit 1

- name: Configure changelog
if: steps.publish.outputs.type != 'none'
run: |
echo '{"categories": [], "template": "## Commits:\n\n${{ '${{UNCATEGORIZED}}' }}", "pr_template": ${{ '"- ${{MERGE_SHA}} ${{TITLE}}"' }} }' > changelog_config.json
cat changelog_config.json
echo "last_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
echo "curr_commit=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Generate changelog
if: steps.publish.outputs.type != 'none'
id: github_release
uses: mikepenz/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
fromTag: "${{ env.last_tag }}"
toTag: ${{ github.ref }}
commitMode: true
configuration: changelog_config.json

- name: Create release
if: steps.publish.outputs.type != 'none'
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.publish.outputs.version }}
release_name: v${{ steps.publish.outputs.version }}
commitish: ${{ github.ref }}
body: ${{steps.github_release.outputs.changelog}}
draft: false
prerelease: false
27 changes: 16 additions & 11 deletions .github/workflows/test.yaml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: Test and Lint
name: test

on:
push:
create:
branches:
- "master"
pull_request:
schedule:
- cron: '44 4 * * SAT'
workflow_dispatch:
branches:
- master

jobs:
test-node:
runs-on: Ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '14' ]
typescript: [ '4.1', '4.2', '4.3', '4.4' ]
typescript: [ '4.1', '4.2', '4.3', '4.4', '4.5', '4.6' ]
name: Test with TypeScript ${{ matrix.typescript }} on Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v2
Expand All @@ -27,16 +27,21 @@ jobs:
- run: yarn test

test-deno:
runs-on: Ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
deno: [ "v1.x" ]
name: Test with Deno ${{ matrix.deno }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
- uses: denolib/setup-deno@v2
with:
deno-version: ${{ matrix.deno }}
- run: yarn install
- run: yarn build:deno
- run: deno --version
- run: deno test
working-directory: ./deno/lib
Expand All @@ -50,7 +55,7 @@ jobs:
working-directory: ./deno/lib

lint:
runs-on: Ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '14' ]
Expand All @@ -61,5 +66,5 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: yarn install
- run: yarn check:format
- run: yarn check:lint
- run: yarn prettier:check
- run: yarn lint:check
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<h1 align="center">Zod</h1>
</p>
<p align="center">
<a href="https://github.com/edgedb/edgedb-js/actions"><img src="https://github.com/colinhacks/zod/workflows/test.yml/badge.svg?event=push&branch=master" alt="Zod CI status" /></a>
<a href="https://twitter.com/colinhacks" rel="nofollow"><img src="https://img.shields.io/badge/created%[email protected]" alt="Created by Colin McDonnell"></a>
<a href="https://opensource.org/licenses/MIT" rel="nofollow"><img src="https://img.shields.io/github/license/colinhacks/zod" alt="License"></a>
<a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/npm/dw/zod.svg" alt="npm"></a>
<a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/github/stars/colinhacks/zod" alt="stars"></a>
<a href="./src/__tests__" rel="nofollow"><img src="./coverage.svg" alt="coverage"></a>
<a href="https://discord.gg/KaSRdyX2vc" rel="nofollow"><img src="https://img.shields.io/discord/893487829802418277?label=Discord&logo=discord&logoColor=white" alt="discord server"></a>
</p>

Expand Down
5 changes: 2 additions & 3 deletions deno/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const nodeSrcRoot = join(projectRoot, "src");
const denoLibRoot = join(projectRoot, "deno", "lib");

const skipList = [join(nodeSrcRoot, "__tests__", "object-in-es5-env.test.ts")];
console.log(skipList);
const walkAndBuild = (/** @type string */ dir) => {
for (const entry of readdirSync(join(nodeSrcRoot, dir), {
withFileTypes: true,
Expand All @@ -37,7 +36,7 @@ const walkAndBuild = (/** @type string */ dir) => {
const denoPath = join(denoLibRoot, dir, entry.name);

if (skipList.includes(nodePath)) {
console.log(`skipping ${nodePath}`);
// console.log(`Skipping ${nodePath}`);
continue;
}

Expand Down Expand Up @@ -74,7 +73,7 @@ const walkAndBuild = (/** @type string */ dir) => {
}
}

console.warn(`Skipping non-resolvable import:\n ${line}`);
// console.warn(`Skipping non-resolvable import:\n ${line}`);
return line;
}
);
Expand Down
2 changes: 1 addition & 1 deletion deno/lib/__tests__/default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { expect } from "https://deno.land/x/[email protected]/mod.ts";
const test = Deno.test;

import { z } from "../index.ts";
import { util } from "../helpers/util.ts";
import { z } from "../index.ts";

test("basic defaults", () => {
expect(z.string().default("default").parse(undefined)).toBe("default");
Expand Down
6 changes: 3 additions & 3 deletions deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2296,7 +2296,7 @@ export class ZodIntersection<
////////////////////////////////////////
////////////////////////////////////////
export type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
export type AssertArray<T extends any> = T extends any[] ? T : never;
export type AssertArray<T> = T extends any[] ? T : never;
export type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
[k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_output"] : never;
}>;
Expand Down Expand Up @@ -2976,12 +2976,12 @@ export class ZodLazy<T extends ZodTypeAny> extends ZodType<
////////// //////////
//////////////////////////////////////////
//////////////////////////////////////////
export interface ZodLiteralDef<T extends any = any> extends ZodTypeDef {
export interface ZodLiteralDef<T = any> extends ZodTypeDef {
value: T;
typeName: ZodFirstPartyTypeKind.ZodLiteral;
}

export class ZodLiteral<T extends any> extends ZodType<T, ZodLiteralDef<T>> {
export class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]> {
if (input.data !== this._def.value) {
const ctx = this._getOrReturnCtx(input);
Expand Down
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "zod",
"version": "3.14.1",
"version": "3.14.2",
"description": "TypeScript-first schema declaration and validation library with static type inference",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"module": "./lib/index.mjs",
"dependencies": {},
"exports": {
".": {
"require": "./lib/index.js",
Expand Down Expand Up @@ -41,12 +42,12 @@
"inference"
],
"scripts": {
"check:format": "prettier --check \"src/**/*.ts\" \"deno/lib/**/*.ts\"",
"fix:format": "prettier --write \"src/**/*.ts\" \"deno/lib/**/*.ts\"",
"check:lint": "eslint --ext .ts ./src",
"fix:lint": "eslint --fix --ext .ts ./src",
"check": "yarn check:lint && yarn check:format",
"fix": "yarn fix:lint && yarn fix:format",
"prettier:check": "prettier --check src/**/*.ts deno/lib/**/*.ts --no-error-on-unmatched-pattern",
"prettier:fix": "prettier --write src/**/*.ts deno/lib/**/*.ts --no-error-on-unmatched-pattern",
"lint:check": "eslint --ext .ts ./src",
"lint:fix": "eslint --fix --ext .ts ./src",
"check": "yarn lint:check && yarn prettier:check",
"fix": "yarn lint:fix && yarn prettier:fix",
"clean": "rm -rf lib/* deno/lib/*",
"build": "yarn run clean && npm run build:cjs && npm run build:esm && npm run build:deno",
"build:deno": "node ./deno/build.mjs",
Expand All @@ -67,8 +68,8 @@
"@types/benchmark": "^2.1.0",
"@types/jest": "^26.0.17",
"@types/node": "^14.14.10",
"@typescript-eslint/eslint-plugin": "^4.11.1",
"@typescript-eslint/parser": "^4.11.1",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"benchmark": "^2.1.4",
"dependency-cruiser": "^9.19.0",
"eslint": "^7.15.0",
Expand All @@ -89,18 +90,18 @@
"ts-jest": "^26.4.4",
"ts-node": "^9.1.0",
"tslib": "^2.3.1",
"typescript": "^4.5.2"
"typescript": "^4.6.2"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && yarn build:deno && git add .",
"pre-push": "lint-staged && yarn build && yarn test && yarn badge"
"pre-commit": "lint-staged",
"pre-push": "lint-staged"
}
},
"lint-staged": {
"*.ts": [
"yarn fix:lint",
"yarn fix:format"
"yarn lint:fix",
"yarn prettier:fix"
]
}
}
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2296,7 +2296,7 @@ export class ZodIntersection<
////////////////////////////////////////
////////////////////////////////////////
export type ZodTupleItems = [ZodTypeAny, ...ZodTypeAny[]];
export type AssertArray<T extends any> = T extends any[] ? T : never;
export type AssertArray<T> = T extends any[] ? T : never;
export type OutputTypeOfTuple<T extends ZodTupleItems | []> = AssertArray<{
[k in keyof T]: T[k] extends ZodType<any, any> ? T[k]["_output"] : never;
}>;
Expand Down Expand Up @@ -2976,12 +2976,12 @@ export class ZodLazy<T extends ZodTypeAny> extends ZodType<
////////// //////////
//////////////////////////////////////////
//////////////////////////////////////////
export interface ZodLiteralDef<T extends any = any> extends ZodTypeDef {
export interface ZodLiteralDef<T = any> extends ZodTypeDef {
value: T;
typeName: ZodFirstPartyTypeKind.ZodLiteral;
}

export class ZodLiteral<T extends any> extends ZodType<T, ZodLiteralDef<T>> {
export class ZodLiteral<T> extends ZodType<T, ZodLiteralDef<T>> {
_parse(input: ParseInput): ParseReturnType<this["_output"]> {
if (input.data !== this._def.value) {
const ctx = this._getOrReturnCtx(input);
Expand Down
Loading