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

Add release workflows #28

Merged
merged 2 commits into from
Sep 6, 2024
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
5 changes: 5 additions & 0 deletions .changeset/five-countries-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-effect-app": patch
---

Initial release
49 changes: 49 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Check

on:
workflow_dispatch:
pull_request:
branches: [main]
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}

jobs:
types:
name: Types
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- run: pnpm check

lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- run: pnpm lint

test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- run: pnpm vitest
env:
NODE_OPTIONS: --max_old_space_size=8192
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

permissions: {}

jobs:
release:
if: github.repository_owner == 'Effect-Ts'
name: Release
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Install dependencies
uses: ./.github/actions/setup
- name: Create Release Pull Request or Publish
uses: changesets/action@v1
with:
version: pnpm changeset-version
publish: pnpm changeset-publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion examples/http-server/src/Accounts/Policy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Effect, Layer } from "effect"
import type { policy } from "../Domain/Policy.js"
import { policy } from "../Domain/Policy.js"
import type { UserId } from "../Domain/User.js"

// eslint-disable-next-line require-yield
const make = Effect.gen(function*() {
const canUpdate = (toUpdate: UserId) => policy("User", "update", (actor) => Effect.succeed(actor.id === toUpdate))

Expand Down
2 changes: 1 addition & 1 deletion examples/http-server/src/Groups.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SqlClient } from "@effect/sql"
import { Cause, Effect, Layer, Option, pipe } from "effect"
import { Effect, Layer, Option, pipe } from "effect"
import type { AccountId } from "./Domain/Account.js"
import type { GroupId } from "./Domain/Group.js"
import { Group, GroupNotFound } from "./Domain/Group.js"
Expand Down
3 changes: 2 additions & 1 deletion examples/http-server/src/Groups/Policy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Effect, Layer } from "effect"
import type { Group } from "../Domain/Group.js"
import type { policy } from "../Domain/Policy.js"
import { policy } from "../Domain/Policy.js"

// eslint-disable-next-line require-yield
const make = Effect.gen(function*() {
const canCreate = (_group: typeof Group.jsonCreate.Type) =>
policy("Group", "create", (_actor) => Effect.succeed(true))
Expand Down
3 changes: 2 additions & 1 deletion examples/http-server/src/Uuid.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Context, Effect, Layer } from "effect"
import * as Api from "uuid"

// eslint-disable-next-line require-yield
const make = Effect.gen(function*() {
const generate = Effect.sync(() => Api.v7())
return { generate } as const
Expand All @@ -10,7 +11,7 @@ export class Uuid extends Context.Tag("Uuid")<
Uuid,
Effect.Effect.Success<typeof make>
>() {
static Live = Layer.effect(Uuid, make)
static Live = Layer.succeed(Uuid, make)
static Test = Layer.succeed(Uuid, {
generate: Effect.succeed("test-uuid")
})
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"type": "module",
"packageManager": "[email protected]",
"workspaces": [
"packages/*",
"examples/*"
"packages/*"
],
"scripts": {
"build": "pnpm --recursive --parallel run build",
Expand Down
1 change: 0 additions & 1 deletion packages/create-effect-app/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"
import * as Ansi from "@effect/printer-ansi/Ansi"
import * as AnsiDoc from "@effect/printer-ansi/AnsiDoc"
import * as Console from "effect/Console"
import * as Effect from "effect/Effect"
import * as Layer from "effect/Layer"
import * as Logger from "effect/Logger"
Expand Down
6 changes: 6 additions & 0 deletions packages/create-effect-app/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { mergeConfig, type UserConfigExport } from "vitest/config"
import shared from "../../vitest.shared.js"

const config: UserConfigExport = {}

export default mergeConfig(shared, config)
3 changes: 3 additions & 0 deletions setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as it from "@effect/vitest"

it.addEqualityTesters()
35 changes: 35 additions & 0 deletions vitest.shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as path from "node:path"
import type { UserConfig } from "vitest/config"

const alias = (name: string) => {
const target = process.env.TEST_DIST !== undefined ? "dist/dist/esm" : "src"
return ({
[`${name}/test`]: path.join(__dirname, "packages", name, "test"),
[`${name}`]: path.join(__dirname, "packages", name, target)
})
}

// This is a workaround, see https://github.com/vitest-dev/vitest/issues/4744
const config: UserConfig = {
esbuild: {
target: "es2020"
},
optimizeDeps: {
exclude: ["bun:sqlite"]
},
test: {
setupFiles: [path.join(__dirname, "setupTests.ts")],
fakeTimers: {
toFake: undefined
},
sequence: {
concurrent: true
},
include: ["test/**/*.test.ts"],
alias: {
...alias("create-effect-app")
}
}
}

export default config
28 changes: 28 additions & 0 deletions vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as path from "node:path"
import { defineWorkspace, type UserWorkspaceConfig } from "vitest/config"

// Remaining issues:
// - Random failures (browser): https://github.com/vitest-dev/vitest/issues/4497
// - Alias resolution (browser, has workaround): https://github.com/vitest-dev/vitest/issues/4744
// - Workspace optimization: https://github.com/vitest-dev/vitest/issues/4746

// TODO: Once https://github.com/vitest-dev/vitest/issues/4497 and https://github.com/vitest-dev/vitest/issues/4746
// are resolved, we can create specialized workspace groups in separate workspace files to better control test groups
// with different dependencies (e.g. playwright browser) in CI.

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const project = (
config: UserWorkspaceConfig["test"] & { name: `${string}|${string}` },
root = config.root ?? path.join(__dirname, `packages/${config.name.split("|").at(0)}`)
) => ({
extends: "vitest.shared.ts",
test: { root, ...config }
})

export default defineWorkspace([
// Add specialized configuration for some packages.
// project({ name: "effect|browser", environment: "happy-dom" }),
// project({ name: "schema|browser", environment: "happy-dom" }),
// Add the default configuration for all packages.
"packages/*"
])