PeerTube/.github/workflows/stats.yml
Chocobozzz 3a4992633e
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge
conflicts, but it's a major step forward:

 * Server can be faster at startup because imports() are async and we can
   easily lazy import big modules
 * Angular doesn't seem to support ES import (with .js extension), so we
   had to correctly organize peertube into a monorepo:
    * Use yarn workspace feature
    * Use typescript reference projects for dependencies
    * Shared projects have been moved into "packages", each one is now a
      node module (with a dedicated package.json/tsconfig.json)
    * server/tools have been moved into apps/ and is now a dedicated app
      bundled and published on NPM so users don't have to build peertube
      cli tools manually
    * server/tests have been moved into packages/ so we don't compile
      them every time we want to run the server
 * Use isolatedModule option:
   * Had to move from const enum to const
     (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums)
   * Had to explictely specify "type" imports when used in decorators
 * Prefer tsx (that uses esbuild under the hood) instead of ts-node to
   load typescript files (tests with mocha or scripts):
     * To reduce test complexity as esbuild doesn't support decorator
       metadata, we only test server files that do not import server
       models
     * We still build tests files into js files for a faster CI
 * Remove unmaintained peertube CLI import script
 * Removed some barrels to speed up execution (less imports)
2023-08-11 15:02:33 +02:00

70 lines
2.3 KiB
YAML

name: Stats
on:
push:
branches:
- develop
- ci
- next
pull_request:
types: [synchronize, opened]
jobs:
stats:
runs-on: ubuntu-latest
env:
CI_BRANCH_BASE: develop
steps:
- uses: actions/checkout@v3
- uses: './.github/actions/reusable-prepare-peertube-build'
with:
node-version: '16.x'
- name: Angular bundlewatch
uses: jackyef/bundlewatch-gh-action@master
with:
build-script: npm run build -- --analyze-bundle
branch-base: develop
bundlewatch-github-token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
- name: PeerTube code stats
if: github.event_name != 'pull_request'
run: |
wget "https://github.com/boyter/scc/releases/download/v3.0.0/scc-3.0.0-x86_64-unknown-linux.zip"
unzip "scc-3.0.0-x86_64-unknown-linux.zip"
./scc --format=json --exclude-dir .git,node_modules,client/node_modules,client/dist,dist,yarn.lock,client/yarn.lock,client/src/locale,test1,test2,test3,client/src/assets/images,config,storage,packages/tests/fixtures,support/openapi,.idea,.vscode,docker-volume,ffmpeg-3,ffmpeg-4 > ./scc.json
- name: PeerTube client stats
if: github.event_name != 'pull_request'
run: |
npm run client:build-stats > client-build-stats.json
- name: PeerTube client lighthouse report
if: github.event_name != 'pull_request'
run: |
sudo apt-get install chromium-browser
sudo npm install -g lighthouse
lighthouse --chrome-flags="--headless" https://peertube2.cpy.re --output=json --output-path=./lighthouse.json
- name: Display stats
if: github.event_name != 'pull_request'
run: |
cat client-build-stats.json
cat scc.json
cat lighthouse.json
- name: Upload stats
if: github.event_name != 'pull_request'
uses: './.github/actions/reusable-deploy'
with:
source: lighthouse.json client-build-stats.json scc.json
destination: peertube-stats
knownHosts: ${{ secrets.STATS_DEPLOYEMENT_KNOWN_HOSTS }}
deployKey: ${{ secrets.STATS_DEPLOYEMENT_KEY }}
deployUser: ${{ secrets.STATS_DEPLOYEMENT_USER }}
deployHost: ${{ secrets.STATS_DEPLOYEMENT_HOST }}