Skip to content

Commit

Permalink
test: create CI tests for turbo v2
Browse files Browse the repository at this point in the history
  • Loading branch information
pkarolyi committed Jun 7, 2024
1 parent 04147f2 commit 39407b1
Show file tree
Hide file tree
Showing 43 changed files with 3,657 additions and 8 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ jobs:
run: pnpm install
- name: Test e2e
run: pnpm test:e2e
test-integration:
name: Test (integration)
test-integration-v1:
name: Test (integration, turbo@^1)
runs-on: ubuntu-22.04
needs: [lint, test, test-e2e]
strategy:
matrix:
turbo_version: ["^1.10", "^1.11", "^1.12", "^1.13", "latest"]
turbo_version: ["^1.10", "^1.11", "^1.12", "^1.13"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -70,6 +70,24 @@ jobs:
- name: Expose GitHub Runtime for caching
uses: crazy-max/ghaction-github-runtime@v3
- name: Build docker images
run: docker compose build
run: docker compose -f integration/compose-v1.yml build
- name: Test API with turborepo
run: docker compose run test ${{ matrix.turbo_version }}
run: docker compose -f integration/compose-v1.yml run test-v1 ${{ matrix.turbo_version }}
test-integration-v2:
name: Test (integration, turbo@^2)
runs-on: ubuntu-22.04
needs: [lint, test, test-e2e]
strategy:
matrix:
turbo_version: ["^2.0", "latest"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up buildx
uses: docker/setup-buildx-action@v3
- name: Expose GitHub Runtime for caching
uses: crazy-max/ghaction-github-runtime@v3
- name: Build docker images
run: docker compose -f integration/compose-v2.yml build
- name: Test API with turborepo
run: docker compose -f integration/compose-v2.yml run test-v2 ${{ matrix.turbo_version }}
6 changes: 3 additions & 3 deletions compose.yml → integration/compose-v1.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
garden-snail:
build:
context: .
context: ..
cache_from:
- type=gha
cache_to:
Expand All @@ -12,9 +12,9 @@ services:
- LOCAL_STORAGE_PATH=blobs
ports:
- "3000:3000"
test:
test-v1:
build:
context: integration
context: v1
cache_from:
- type=gha
cache_to:
Expand Down
23 changes: 23 additions & 0 deletions integration/compose-v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
services:
garden-snail:
build:
context: ..
cache_from:
- type=gha
cache_to:
- type=gha,mode=max
environment:
- AUTH_TOKENS=TEST_TOKEN_NOT_SECRET
- STORAGE_PROVIDER=local
- LOCAL_STORAGE_PATH=blobs
ports:
- "3000:3000"
test-v2:
build:
context: v2
cache_from:
- type=gha
cache_to:
- type=gha,mode=max
depends_on:
- garden-snail
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions integration/v2/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Dockerfile
**/.next
**/node_modules
**/next-env.d.ts
15 changes: 15 additions & 0 deletions integration/v2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20.12.2-alpine3.18

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"

RUN npm install -g --ignore-scripts [email protected]

COPY ./turbo-test-project ./turbo-test-project

WORKDIR /turbo-test-project
RUN pnpm install --frozen-lockfile

COPY ./integration.run.sh .

ENTRYPOINT ["sh", "integration.run.sh"]
40 changes: 40 additions & 0 deletions integration/v2/integration.run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

set -e

turbo_version="$1"

if [ -z "$turbo_version" ]
then
echo "Usage: $0 <turbo_version>"
exit 2
fi

echo "Testing with turbo version: $turbo_version"

echo "Installing turbo@$turbo_version ..."
pnpm add "turbo@$turbo_version" --global


echo "Running first build ..."
pnpm exec turbo build

echo "Removing local cache files ..."
rm -r ./.turbo/cache ./.next

echo "Running second build ..."
build_output=$(pnpm exec turbo build)

echo "$build_output"

if (echo "$build_output" | grep -q "Remote caching enabled") \
&& (echo "$build_output" | grep -q "cache hit, replaying logs") \
&& (echo "$build_output" | grep -q "FULL TURBO")
then
echo "SUCCESS"
exit 0
else
echo "FAILURE"
exit 1
fi

3 changes: 3 additions & 0 deletions integration/v2/turbo-test-project/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
39 changes: 39 additions & 0 deletions integration/v2/turbo-test-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

.turbo/*
!.turbo/config.json
5 changes: 5 additions & 0 deletions integration/v2/turbo-test-project/.turbo/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"token": "TEST_TOKEN_NOT_SECRET",
"apiurl": "http://garden-snail:3000",
"teamid": "team_testing"
}
36 changes: 36 additions & 0 deletions integration/v2/turbo-test-project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Binary file added integration/v2/turbo-test-project/app/favicon.ico
Binary file not shown.
33 changes: 33 additions & 0 deletions integration/v2/turbo-test-project/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}

@layer utilities {
.text-balance {
text-wrap: balance;
}
}
19 changes: 19 additions & 0 deletions integration/v2/turbo-test-project/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Metadata } from "next";
import "./globals.css";

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
Loading

0 comments on commit 39407b1

Please sign in to comment.