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 nightly build check workflow #51

Merged
merged 5 commits into from
Sep 19, 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
108 changes: 108 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Nightly Checks

on:
workflow_dispatch:
pull_request:
branches: [main]
push:
branches: [main]
schedule:
# Run checks nightly at midnight
- cron: '0 0 * * *'

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

permissions: {}

jobs:
prepare:
name: Prepare Targets
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
examples: ${{ steps.targets.outputs.examples }}
templates: ${{ steps.targets.outputs.templates }}
steps:
- uses: actions/checkout@v4
- name: Find all build targets
id: targets
run: |
examples=$(
find templates -mindepth 1 -maxdepth 1 -type d |
jq -cnR '[inputs | select(length > 0)]'
)
templates=$(
find templates -mindepth 1 -maxdepth 1 -type d |
jq -cnR '[inputs | select(length > 0)]'
)
echo "examples=${examples}" >> $GITHUB_OUTPUT
echo "templates=${templates}" >> $GITHUB_OUTPUT

examples:
name: Check Examples
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [prepare]
strategy:
matrix:
example: ${{ fromJSON(needs.prepare.outputs.examples) }}
fail-fast: true
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: ${{ matrix.example }}
sparse-checkout-cone-mode: false
- name: Move files to root
run: |
ls -lah
shopt -s dotglob
mv ${{ matrix.example }}/* .
rm -rf examples
ls -lah
- name: Install pnpm
uses: pnpm/action-setup@v3
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20.14.0
- name: Install dependencies
run: pnpm install
- run: pnpm lint
- run: pnpm check
- run: pnpm test

templates:
name: Check Templates
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [prepare]
strategy:
matrix:
template: ${{ fromJSON(needs.prepare.outputs.templates) }}
fail-fast: true
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: ${{ matrix.template }}
sparse-checkout-cone-mode: false
- name: Move files to root
run: |
ls -lah
shopt -s dotglob
mv ${{ matrix.template }}/* .
rm -rf templates
ls -lah
- name: Install pnpm
uses: pnpm/action-setup@v3
- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20.14.0
- name: Install dependencies
run: pnpm install
- run: pnpm lint
- run: pnpm check
- run: pnpm build
- run: pnpm test
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
[![Nightly Build](https://github.com/Effect-TS/examples/workflows/Nightly%20Checks/badge.svg)](https://github.com/Effect-TS/examples/actions)

# Effect Examples

## Create Effect App

The easiest way to get started with Effect is by using `create-effect-app`.
The easiest way to get started with Effect is by using `create-effect-app`.

This CLI tool enables you to quickly bootstrap a project with Effect, with everything pre-configured for you.
This CLI tool enables you to quickly bootstrap a project with Effect, with everything pre-configured for you.

You can create a new project using one of our [project templates](./templates) or by using one of the [official Effect examples](./examples).
You can create a new project using one of our [project templates](./templates) or by using one of the [official Effect examples](./examples).

See [the documentation](./packages/create-effect-app/README.md) for more information.

Expand All @@ -22,13 +24,13 @@ The available examples include:

## Templates

This repository contains templates which can be used to quickly bootstrap a new project with Effect via the `create-effect-app` CLI tool.
This repository contains templates which can be used to quickly bootstrap a new project with Effect via the `create-effect-app` CLI tool.

These templates were developed to mirror the project configuration recommneded by the Effect core team and are thus somewhat opinionated.

### Basic

The `basic` template is meant to serve as the foundation for building a single package or library with Effect.
The `basic` template is meant to serve as the foundation for building a single package or library with Effect.

The template features:

Expand All @@ -44,7 +46,7 @@ For more information, see the template [README](./templates/basic/README.md).

### Monorepo

The `monorepo` template is meant to serve as the foundation for building multiple packages or applications with Effect.
The `monorepo` template is meant to serve as the foundation for building multiple packages or applications with Effect.

The template features everything included with the `basic` template in addition to:

Expand All @@ -61,4 +63,3 @@ The template features everything included with the `basic` template, except with
- Pre-configured build pipeline is via [`tsup`](https://github.com/egoist/tsup) to support bundling to a single file

For more information, see the template [README](./templates/cli/README.md).

3 changes: 0 additions & 3 deletions examples/http-server/.prettierrc.json

This file was deleted.

122 changes: 122 additions & 0 deletions examples/http-server/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import { fixupPluginRules } from "@eslint/compat"
import { FlatCompat } from "@eslint/eslintrc"
import js from "@eslint/js"
import tsParser from "@typescript-eslint/parser"
import codegen from "eslint-plugin-codegen"
import deprecation from "eslint-plugin-deprecation"
import _import from "eslint-plugin-import"
import simpleImportSort from "eslint-plugin-simple-import-sort"
import sortDestructureKeys from "eslint-plugin-sort-destructure-keys"
import path from "node:path"
import { fileURLToPath } from "node:url"

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
})

export default [
{
ignores: ["**/dist", "**/build", "**/docs", "**/*.md"]
},
...compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@effect/recommended"
),
{
plugins: {
deprecation,
import: fixupPluginRules(_import),
"sort-destructure-keys": sortDestructureKeys,
"simple-import-sort": simpleImportSort,
codegen
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2018,
sourceType: "module"
},

settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},

"import/resolver": {
typescript: {
alwaysTryTypes: true
}
}
},

rules: {
"codegen/codegen": "error",
"no-fallthrough": "off",
"no-irregular-whitespace": "off",
"object-shorthand": "error",
"prefer-destructuring": "off",
"sort-imports": "off",

"no-restricted-syntax": ["error", {
selector: "CallExpression[callee.property.name='push'] > SpreadElement.arguments",
message: "Do not use spread arguments in Array.push"
}],

"no-unused-vars": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"import/no-unresolved": "off",
"import/order": "off",
"simple-import-sort/imports": "off",
"sort-destructure-keys/sort-destructure-keys": "error",
"deprecation/deprecation": "off",

"@typescript-eslint/array-type": ["warn", {
default: "generic",
readonly: "generic"
}],

"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/consistent-type-imports": "warn",

"@typescript-eslint/no-unused-vars": ["error", {
argsIgnorePattern: "^_",
varsIgnorePattern: "^_"
}],

"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-array-constructor": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-namespace": "off",

"@effect/dprint": ["error", {
config: {
indentWidth: 2,
lineWidth: 120,
semiColons: "asi",
quoteStyle: "alwaysDouble",
trailingCommas: "never",
operatorPosition: "maintain",
"arrowFunction.useParentheses": "force"
}
}]
}
}
]
15 changes: 15 additions & 0 deletions examples/http-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"type": "module",
"description": "",
"scripts": {
"check": "tsc -b tsconfig.json",
"dev": "tsx --env-file=.env --watch src/main.ts",
"lint": "eslint \"**/{src,test,examples,scripts,dtslint}/**/*.{ts,mjs}\"",
"lint-fix": "pnpm lint --fix",
"test": "vitest"
},
"keywords": [],
Expand All @@ -29,10 +32,22 @@
"@effect/schema": "^0.72.1",
"@effect/sql": "^0.10.1",
"@effect/sql-sqlite-node": "^0.10.1",
"@eslint/compat": "1.1.1",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.10.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.53.0",
"@opentelemetry/sdk-trace-base": "^1.26.0",
"@opentelemetry/sdk-trace-node": "^1.26.0",
"@typescript-eslint/eslint-plugin": "^8.4.0",
"@typescript-eslint/parser": "^8.4.0",
"effect": "^3.7.1",
"eslint": "^9.10.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-codegen": "^0.28.0",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-sort-destructure-keys": "^2.0.0",
"uuid": "^10.0.0"
}
}
2 changes: 1 addition & 1 deletion examples/http-server/src/Accounts/Policy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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
Expand Down
2 changes: 1 addition & 1 deletion examples/http-server/src/Groups/Policy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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*() {
Expand Down
2 changes: 1 addition & 1 deletion examples/http-server/src/People/Policy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Effect, Layer, pipe } from "effect"
import type { GroupId } from "../Domain/Group.js"
import type { Person, PersonId } from "../Domain/Person.js"
import type { policy, policyCompose, Unauthorized } from "../Domain/Policy.js"
import { policy, policyCompose, Unauthorized } from "../Domain/Policy.js"
import { Groups } from "../Groups.js"
import { GroupsPolicy } from "../Groups/Policy.js"
import { People } from "../People.js"
Expand Down
Loading