Skip to content

Commit 170aba2

Browse files
committed
merge CI
1 parent d28058f commit 170aba2

2 files changed

Lines changed: 96 additions & 98 deletions

File tree

.github/workflows/ci.yml

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
name: CI
22

33
on:
4+
workflow_dispatch:
45
pull_request:
56
push:
67
branches:
78
- main
89
tags:
910
- '*'
11+
schedule:
12+
- cron: '0 8 * * *'
1013

1114
jobs:
1215
pack:
16+
name: Build package
1317
runs-on: ubuntu-latest
1418
steps:
1519
- uses: actions/checkout@v4
@@ -24,6 +28,7 @@ jobs:
2428
path: '*.tgz'
2529

2630
biome:
31+
name: Lint (Biome)
2732
runs-on: ubuntu-latest
2833
steps:
2934
- uses: actions/checkout@v4
@@ -34,6 +39,7 @@ jobs:
3439
- run: corepack yarn lint:js
3540

3641
typescript:
42+
name: Lint (TypeScript)
3743
runs-on: ubuntu-latest
3844
steps:
3945
- uses: actions/checkout@v4
@@ -43,7 +49,8 @@ jobs:
4349
- run: corepack yarn
4450
- run: corepack yarn lint:ts
4551

46-
vitest:
52+
unit:
53+
name: Unit tests (Node ${{ matrix.node }})
4754
runs-on: ubuntu-latest
4855
strategy:
4956
matrix:
@@ -58,14 +65,86 @@ jobs:
5865
- run: corepack yarn
5966
- run: corepack yarn test:unit
6067
- name: Upload coverage reports artifact
61-
if: matrix.node == 22 # Only upload coverage from the latest Node.js version
68+
if: matrix.node == 22
6269
uses: actions/upload-artifact@v4
6370
with:
6471
name: coverage-reports
6572
path: coverage/
6673

74+
e2e:
75+
name: E2E tests (Node ${{ matrix.node }})
76+
# Run on push/schedule/dispatch, or on PRs only if from same repo (not forks)
77+
# This protects secrets from being exposed to fork PRs
78+
if: >
79+
github.event_name != 'pull_request' ||
80+
github.event.pull_request.head.repo.full_name == github.repository
81+
runs-on: ubuntu-latest
82+
strategy:
83+
# e2e tests are not yet ready to run in parallel
84+
max-parallel: 1
85+
matrix:
86+
node:
87+
- 20
88+
- 22
89+
steps:
90+
- uses: actions/checkout@v4
91+
- uses: actions/setup-node@v4
92+
with:
93+
node-version: ${{ matrix.node }}
94+
- run: corepack yarn
95+
- name: Download cloudflared
96+
run: |
97+
curl -fsSLo cloudflared-linux-amd64 https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
98+
chmod +x cloudflared-linux-amd64
99+
100+
# can be used for debugging:
101+
# - name: Setup tmate session
102+
# uses: mxschmitt/action-tmate@v3
103+
104+
- run: corepack yarn test
105+
env:
106+
TRANSLOADIT_KEY: ${{ secrets.TRANSLOADIT_KEY }}
107+
TRANSLOADIT_SECRET: ${{ secrets.TRANSLOADIT_SECRET }}
108+
NODE_OPTIONS: --trace-deprecation --trace-warnings
109+
CLOUDFLARED_PATH: ./cloudflared-linux-amd64
110+
DEBUG: 'transloadit:*'
111+
112+
- if: matrix.node == 22
113+
name: Generate the badge from the json-summary
114+
run: node --experimental-strip-types test/generate-coverage-badge.ts coverage/coverage-summary.json
115+
- if: matrix.node == 22
116+
name: Move HTML report and badge to the correct location
117+
run: |
118+
mv coverage/lcov-report static-build
119+
mv coverage-badge.svg static-build/
120+
# *** BEGIN PUBLISH STATIC SITE STEPS ***
121+
# Use the standard checkout action to check out the destination repo to a separate directory
122+
# See https://github.com/mifi/github-action-push-static
123+
- if: matrix.node == 22
124+
uses: actions/checkout@v4
125+
with:
126+
ssh-key: ${{ secrets.COVERAGE_REPO_SSH_PRIVATE_KEY }}
127+
repository: transloadit/node-sdk-coverage
128+
path: static-files-destination
129+
130+
# Push coverage data
131+
- if: matrix.node == 22
132+
run: |
133+
git config --global user.name github-actions
134+
git config --global user.email github-actions@github.com
135+
# Remove existing files:
136+
rm -rf static-files-destination/*
137+
# Replace with new files:
138+
cp -a static-build/* static-files-destination/
139+
cd static-files-destination
140+
git add .
141+
# git diff-index: to avoid doing the git commit failing if there are no changes to be commit
142+
git diff-index --quiet HEAD || git commit --message 'Static file updates'
143+
git push
144+
67145
coverage:
68-
needs: vitest
146+
name: Upload coverage
147+
needs: unit
69148
runs-on: ubuntu-latest
70149
if: github.ref == 'refs/heads/main'
71150
steps:
@@ -83,13 +162,26 @@ jobs:
83162
name: node-sdk
84163
fail_ci_if_error: true
85164

165+
slack-on-failure:
166+
name: Slack notification
167+
needs: [e2e]
168+
if: ${{ failure() && github.ref == 'refs/heads/main' }}
169+
runs-on: ubuntu-latest
170+
steps:
171+
- uses: 8398a7/action-slack@v3
172+
with:
173+
status: failure
174+
env:
175+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
176+
86177
release:
178+
name: Publish to npm
87179
runs-on: ubuntu-latest
88180
needs:
89181
- pack
90182
- biome
91183
- typescript
92-
- vitest
184+
- unit
93185
if: startsWith(github.ref, 'refs/tags/')
94186
permissions:
95187
id-token: write

.github/workflows/e2e.yml

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)