Skip to content

Incorporate CLI that supports all transloadify commands #388

Incorporate CLI that supports all transloadify commands

Incorporate CLI that supports all transloadify commands #388

Workflow file for this run

name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
tags:
- '*'
schedule:
- cron: '0 8 * * *'
jobs:
pack:
name: Build package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: corepack yarn
- run: corepack yarn pack
- uses: actions/upload-artifact@v4
with:
name: package
path: '*.tgz'
biome:
name: Lint (Biome)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: corepack yarn
- run: corepack yarn lint:js
typescript:
name: Lint (TypeScript)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: corepack yarn
- run: corepack yarn lint:ts
unit:
name: Unit tests (Node ${{ matrix.node }})
runs-on: ubuntu-latest
strategy:
matrix:
node:
- 20
- 22
- 24
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: corepack yarn
- run: corepack yarn test:unit
- name: Upload coverage reports artifact
if: matrix.node == 24
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: coverage/
e2e:
name: E2E tests
# Run on push/schedule/dispatch, or on PRs only if from same repo (not forks)
# This protects secrets from being exposed to fork PRs
if: >
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- run: corepack yarn
- name: Download cloudflared
run: |
curl -fsSLo cloudflared-linux-amd64 https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
chmod +x cloudflared-linux-amd64
# can be used for debugging:
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- run: corepack yarn test
env:
TRANSLOADIT_KEY: ${{ secrets.TRANSLOADIT_KEY }}
TRANSLOADIT_SECRET: ${{ secrets.TRANSLOADIT_SECRET }}
NODE_OPTIONS: --trace-deprecation --trace-warnings
CLOUDFLARED_PATH: ./cloudflared-linux-amd64
DEBUG: 'transloadit:*'
- name: Generate the badge from the json-summary
run: node --experimental-strip-types test/generate-coverage-badge.ts coverage/coverage-summary.json
- name: Move HTML report and badge to the correct location
run: |
mv coverage/lcov-report static-build
mv coverage-badge.svg static-build/
# *** BEGIN PUBLISH STATIC SITE STEPS ***
# Use the standard checkout action to check out the destination repo to a separate directory
# See https://github.com/mifi/github-action-push-static
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.COVERAGE_REPO_SSH_PRIVATE_KEY }}
repository: transloadit/node-sdk-coverage
path: static-files-destination
# Push coverage data
- run: |
git config --global user.name github-actions
git config --global user.email github-actions@github.com
# Remove existing files:
rm -rf static-files-destination/*
# Replace with new files:
cp -a static-build/* static-files-destination/
cd static-files-destination
git add .
# git diff-index: to avoid doing the git commit failing if there are no changes to be commit
git diff-index --quiet HEAD || git commit --message 'Static file updates'
git push
coverage:
name: Upload coverage
needs: unit
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: coverage-reports
path: coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: unittests
name: node-sdk
fail_ci_if_error: true
slack-on-failure:
name: Slack notification
needs: [e2e]
if: ${{ failure() && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- uses: 8398a7/action-slack@v3
with:
status: failure
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
release:
name: Publish to npm
runs-on: ubuntu-latest
needs:
- pack
- biome
- typescript
- unit
if: startsWith(github.ref, 'refs/tags/')
permissions:
id-token: write
contents: write
steps:
- uses: softprops/action-gh-release@v1
with:
draft: true
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- uses: actions/download-artifact@v4
with: { name: package }
- run: npm publish *.tgz --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}