Skip to content

Commit

Permalink
ci: add jobs to test, lint, and build packages on every commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ianlet committed Sep 28, 2024
1 parent 5876390 commit 011211b
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 58 deletions.
125 changes: 125 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# Tuesdays at 14:45 UTC (10:45 EST)
- cron: 45 14 * * 1

permissions:
contents: read # for checkout

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

jobs:
main:
# ignore all-contributors PRs
if: ${{ !contains(github.head_ref, 'all-contributors') }}
name: Node ${{ matrix.node }}, Qwik ${{ matrix.qwik }}, ${{ matrix.check }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node: [ '16', '18', '20', '22' ]
qwik: [ '1.7', '1.8', '1.9' ]
check: [ 'test' ]
include:
- { node: '22', qwik: '1.9', check: 'lint' }
- { node: '22', qwik: 'next', check: 'test' }

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🧱 Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: 📥 Download deps
run: |
pnpm install --no-package-lock
pnpm install --no-save @builder.io/qwik@${{ matrix.qwik }}
- name: ▶️ Run ${{ matrix.check }}
run: npm ${{ matrix.check }}

build:
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🧱 Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: 📥 Download deps
run: pnpm install

- name: 🏗️ Build packages
run: pnpm build

release:
name: Release
needs: [ main, build ]
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🧱 Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: 📥 Download deps
run: pnpm install

- name: 🏗️ Build packages
run: pnpm release:prepare

- name: 🚀 Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm release
47 changes: 0 additions & 47 deletions .github/workflows/release.yml

This file was deleted.

5 changes: 4 additions & 1 deletion apps/qwik-basic-demo/src/components/qwik-component.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ describe("<QwikComponent />", () => {
});

it("should handle multiple events", async () => {
await render(<QwikComponent onClick$={[firstEvent, secondEvent]} />);
await render(
// eslint-disable-next-line qwik/valid-lexical-scope
<QwikComponent onFirst$={firstEvent} onSecond$={secondEvent} />,
);

const eventsBtn = screen.getByRole("button", {
name: /fire events/,
Expand Down
18 changes: 9 additions & 9 deletions apps/qwik-basic-demo/src/components/qwik-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {
$,
component$,
createContextId,
Fragment,
noSerialize,
NoSerialize,
QRLEventHandlerMulti,
PropsOf,
QRL,
Resource,
Slot,
useComputed$,
Expand All @@ -20,14 +20,15 @@ import {

export const MyContext = createContextId<{ item: string }>("my-context");

interface QwikComponentProps {
interface QwikComponentProps extends PropsOf<"div"> {
myProp?: string;
items?: string[];
onClick$?: QRLEventHandlerMulti<MouseEvent, HTMLButtonElement>;
onFirst$?: QRL<() => void>;
onSecond$?: QRL<() => void>;
}

export const QwikComponent = component$<QwikComponentProps>(
({ myProp = "qwik-prop", items = [], onClick$ }) => {
({ myProp = "qwik-prop", items = [], onFirst$, onSecond$ }) => {
const mySig = useSignal("my-signal");
const propSig = useSignal(myProp);
const conditionalSig = useSignal(false);
Expand All @@ -50,13 +51,12 @@ export const QwikComponent = component$<QwikComponentProps>(
const taskSig = useSignal("");

useTask$(({ track }) => {
const value = track(trackedSig);

taskSig.value = value;
taskSig.value = track(trackedSig);
});

const nonSerializableSig = useSignal<NoSerialize<MyClass>>();

// eslint-disable-next-line qwik/no-use-visible-task
useVisibleTask$(() => {
nonSerializableSig.value = noSerialize(
new MyClass("non-serializable-value"),
Expand Down Expand Up @@ -123,7 +123,7 @@ export const QwikComponent = component$<QwikComponentProps>(
<button onClick$={changeTrackedValue}>change tracked</button>
<button onClick$={changeCondition}>change condition</button>

<button onClick$={onClick$}>fire events</button>
<button onClick$={[onFirst$, onSecond$]}>fire events</button>
</div>
);
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"toc": "doctoc README.md",
"test": "pnpm -r test",
"fmt": "pnpm -r fmt",
"validate": "pnpm --filter '{packages/qwik-testing-library}' run validate && pnpm --filter '{apps/qwik-basic-demo}' run validate",
"lint": "pnpm -r lint",
"validate": "pnpm -r lint && pnpm -r validate",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate",
"build": "pnpm --filter '{packages/qwik-testing-library}' run build",
Expand Down

0 comments on commit 011211b

Please sign in to comment.