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 tests project with cypress e2e tests #1553

Merged
merged 9 commits into from
Jan 2, 2023
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
30 changes: 14 additions & 16 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
node_modules
.nuxt
.github
.git
data
dist
out
channels
scripts
client/node_modules
client/.output
client/.nuxt
server/node_modules
server/dist

Dockerfile
# Files
Dockerfile
npm-debug.log
.all-contributorsrc
.editorconfig
Expand All @@ -31,6 +16,19 @@ docker-compose.yml
# Folders
.github
.vscode
.nuxt
.git
ddata
data
node_modules
data
dist
out
channels
tests
scripts
client/node_modules
client/.output
client/.nuxt
server/node_modules
server/dist
3 changes: 0 additions & 3 deletions .github/workflows/build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v3

# - name: Setup QEMU
# uses: docker/setup-qemu-action@v2

Expand Down
36 changes: 27 additions & 9 deletions .github/workflows/pr-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
node-version: 18.x

- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 7
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup pnpm cache
uses: actions/cache@v3
Expand All @@ -49,16 +49,34 @@ jobs:
- name: Run ${{ matrix.command }}
run: NODE_OPTIONS=--max-old-space-size=4096 pnpm run ${{ matrix.command }}

docker:
name: docker build
e2e:
name: e2e tests
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Build Docker image
uses: docker/build-push-action@v3
- name: Node.js PR workflow step ${{ matrix.command }}
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Setup pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 7
run_install: false

- name: Install e2e test dependencies
run: pnpm --filter=./tests install --frozen-lockfile

- name: Prepare docker environment and run e2e tests
run: pnpm run e2e

- name: Upload e2e test results
uses: actions/upload-artifact@v3
if: always()
with:
context: .
push: false
cache-from: type=registry,ref=mauriceo/viewtube:dev
name: e2e-test-results
path: ./tests/cypress/videos/
7 changes: 3 additions & 4 deletions .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,25 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "pnpm"

- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 7
run_install: false

- name: Get current date and time
id: date-time
run: echo "::set-output name=date-time::$(TZ='Europe/Zurich' date +'%Y-%m-%d %H:%M:%S %Z')"
run: echo "date-time=$(TZ='Europe/Zurich' date +'%Y-%m-%d %H:%M:%S %Z') >> $GITHUB_OUTPUT"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run tests
id: run_tests
run: |
echo "::set-output name=test-result::$(pnpm test | tail)"
echo "test-result=$(pnpm test | tail)" >> $GITHUB_OUTPUT

- name: Send test status notification
if: always()
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ output/*

dump.rdb

# Test files
tests/cypress/screenshots
tests/cypress/videos
tests/cypress/downloads

Dockerfile.nodejs-mongodb
.vscode/.ropeproject/
server/config.json
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ COPY --from=build /home/build/server/dist ./server/dist/

COPY --from=build /home/build/client/.output ./client/.output/

RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
RUN \
--mount=type=cache,target=/var/cache/apt \
apt-get update \
&& apt-get install -y --no-install-recommends wget \
&& rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

ENV VIEWTUBE_BASE_DIR=/home/app
Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@
"pnpm": ">=7.3.0"
},
"scripts": {
"build": "pnpm --filter='*' run build",
"build:server": "pnpm --filter='./server' run build",
"build:client": "pnpm --filter='./client' run build",
"build": "pnpm --filter=* run build",
"build:server": "pnpm --filter=./server run build",
"build:client": "pnpm --filter=./client run build",
"serve:env": "docker-compose -f docker-compose.dev.yml up -d",
"serve:server": "pnpm --filter='./server' run serve",
"serve:client": "pnpm --filter='./client' run serve",
"test": "pnpm --filter='./server' run test",
"start": "pnpm --filter='./server' run start",
"serve:server": "pnpm --filter=./server run serve",
"serve:client": "pnpm --filter=./client run serve",
"test": "pnpm --filter=./server run test",
"start": "pnpm --filter=./server run start",
"lint-staged": "prettier --write --ignore-unknown",
"lint:client": "pnpm --filter='./client' run lint",
"lint:server": "pnpm --filter='./server' run lint",
"lint:client": "pnpm --filter=./client run lint",
"lint:server": "pnpm --filter=./server run lint",
"e2e": "pnpm --filter=./tests run test",
"format": "prettier --write ."
},
"browserslist": [
Expand Down
Loading