]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - .github/workflows/stats.yml
Trigger a build for any branch
[github/Chocobozzz/PeerTube.git] / .github / workflows / stats.yml
1 name: "Stats"
2
3 on:
4 push:
5 pull_request:
6 types: [synchronize, opened]
7
8 jobs:
9
10 stats:
11 runs-on: ubuntu-latest
12
13 env:
14 CI_BRANCH_BASE: develop
15
16 steps:
17 - uses: actions/checkout@v2
18
19 - name: Use Node.js
20 uses: actions/setup-node@v1
21 with:
22 node-version: '12.x'
23
24 - name: Cache Node.js modules
25 uses: actions/cache@v2
26 with:
27 path: |
28 **/node_modules
29 key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }}
30 restore-keys: |
31 ${{ runner.OS }}-node-
32 ${{ runner.OS }}-
33
34 - name: Install dependencies
35 run: yarn install --frozen-lockfile
36
37 - name: Angular bundlewatch
38 uses: jackyef/bundlewatch-gh-action@master
39 with:
40 build-script: npm run build -- --analyze-bundle
41 branch-base: develop
42 bundlewatch-github-token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
43
44 - name: PeerTube code stats
45 if: github.event_name != 'pull_request'
46 run: |
47 wget "https://github.com/boyter/scc/releases/download/v3.0.0/scc-3.0.0-x86_64-unknown-linux.zip"
48 unzip "scc-3.0.0-x86_64-unknown-linux.zip"
49 ./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,server/tests/fixtures,support/openapi,.idea,.vscode,docker-volume,ffmpeg-3,ffmpeg-4 > ./scc.json
50
51 - name: PeerTube client stats
52 if: github.event_name != 'pull_request'
53 run: |
54 node dist/scripts/client-build-stats.js > client-build-stats.json
55
56 - name: PeerTube client lighthouse report
57 if: github.event_name != 'pull_request'
58 run: |
59 sudo apt-get install chromium-browser
60 sudo npm install -g lighthouse
61 lighthouse --chrome-flags="--headless" https://peertube2.cpy.re --output=json --output-path=./lighthouse.json
62
63 - name: Display stats
64 if: github.event_name != 'pull_request'
65 run: |
66 cat client-build-stats.json
67 cat scc.json
68 cat lighthouse.json
69
70 - name: Upload stats
71 if: github.event_name != 'pull_request'
72 env:
73 STATS_DEPLOYEMENT_KNOWN_HOSTS: ${{ secrets.STATS_DEPLOYEMENT_KNOWN_HOSTS }}
74 STATS_DEPLOYEMENT_KEY: ${{ secrets.STATS_DEPLOYEMENT_KEY }}
75 STATS_DEPLOYEMENT_USER: ${{ secrets.STATS_DEPLOYEMENT_USER }}
76 STATS_DEPLOYEMENT_HOST: ${{ secrets.STATS_DEPLOYEMENT_HOST }}
77 run: |
78 mkdir -p ~/.ssh
79 chmod 700 ~/.ssh
80 if [ ! -z ${STATS_DEPLOYEMENT_KNOWN_HOSTS+x} ]; then
81 echo "Adding ssh key to known hosts"
82 echo -e "${STATS_DEPLOYEMENT_KNOWN_HOSTS}" > ~/.ssh/known_hosts;
83 fi
84
85 eval `ssh-agent -s`
86
87 if [ ! -z ${STATS_DEPLOYEMENT_KEY+x} ]; then
88 echo "Adding ssh reployement key"
89 ssh-add <(echo "${STATS_DEPLOYEMENT_KEY}");
90 fi
91
92 if [ ! -z ${STATS_DEPLOYEMENT_KEY+x} ]; then
93 echo "Uploading files"
94 scp lighthouse.json client-build-stats.json scc.json ${STATS_DEPLOYEMENT_USER}@${STATS_DEPLOYEMENT_HOST}:../../web/peertube-stats;
95 fi