From 3a1157a68a70e90df21f743ea15154805649b8e5 Mon Sep 17 00:00:00 2001 From: John Livingston <38844060+JohnXLivingston@users.noreply.github.com> Date: Fri, 3 Dec 2021 10:14:01 +0100 Subject: [PATCH 01/28] CLI: plugins install command accept a --plugin-version parameter. (#4599) * CLI: plugins install command accept a --plugin-version parameter. * Unit tests for plugins install --plugin-version. * Fix linting. * Styling Co-authored-by: Chocobozzz --- server/controllers/api/plugins.ts | 7 ++++++- server/middlewares/validators/plugins.ts | 6 ++++++ server/tests/cli/peertube.ts | 19 +++++++++++++++++++ server/tools/peertube-plugins.ts | 3 ++- shared/extra-utils/server/plugins-command.ts | 5 +++-- .../server/api/install-plugin.model.ts | 1 + 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts index 2de7fe41f..de9e055dc 100644 --- a/server/controllers/api/plugins.ts +++ b/server/controllers/api/plugins.ts @@ -144,8 +144,13 @@ async function installPlugin (req: express.Request, res: express.Response) { const fromDisk = !!body.path const toInstall = body.npmName || body.path + + const pluginVersion = body.pluginVersion && body.npmName + ? body.pluginVersion + : undefined + try { - const plugin = await PluginManager.Instance.install(toInstall, undefined, fromDisk) + const plugin = await PluginManager.Instance.install(toInstall, pluginVersion, fromDisk) return res.json(plugin.toFormattedJSON()) } catch (err) { diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts index 21171af23..c1e9ebefb 100644 --- a/server/middlewares/validators/plugins.ts +++ b/server/middlewares/validators/plugins.ts @@ -116,6 +116,9 @@ const installOrUpdatePluginValidator = [ body('npmName') .optional() .custom(isNpmPluginNameValid).withMessage('Should have a valid npm name'), + body('pluginVersion') + .optional() + .custom(isPluginVersionValid).withMessage('Should have a valid plugin version'), body('path') .optional() .custom(isSafePath).withMessage('Should have a valid safe path'), @@ -129,6 +132,9 @@ const installOrUpdatePluginValidator = [ if (!body.path && !body.npmName) { return res.fail({ message: 'Should have either a npmName or a path' }) } + if (body.pluginVersion && !body.npmName) { + return res.fail({ message: 'Should have a npmName when specifying a pluginVersion' }) + } return next() } diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index f2a984962..3ac440f84 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -207,6 +207,25 @@ describe('Test CLI wrapper', function () { expect(res).to.not.contain('peertube-plugin-hello-world') }) + + it('Should install a plugin in requested version', async function () { + this.timeout(60000) + + await cliCommand.execWithEnv(`${cmd} plugins install --npm-name peertube-plugin-hello-world --plugin-version 0.0.17`) + }) + + it('Should list installed plugins, in correct version', async function () { + const res = await cliCommand.execWithEnv(`${cmd} plugins list`) + + expect(res).to.contain('peertube-plugin-hello-world') + expect(res).to.contain('0.0.17') + }) + + it('Should uninstall the plugin again', async function () { + const res = await cliCommand.execWithEnv(`${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`) + + expect(res).to.not.contain('peertube-plugin-hello-world') + }) }) describe('Manage video redundancies', function () { diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts index ae625114d..9dd3f08c9 100644 --- a/server/tools/peertube-plugins.ts +++ b/server/tools/peertube-plugins.ts @@ -31,6 +31,7 @@ program .option('-p, --password ', 'Password') .option('-P --path ', 'Install from a path') .option('-n, --npm-name ', 'Install from npm') + .option('--plugin-version ', 'Specify the plugin version to install (only available when installing from npm)') .action((options, command) => installPluginCLI(command, options)) program @@ -109,7 +110,7 @@ async function installPluginCLI (command: Command, options: OptionValues) { await assignToken(server, username, password) try { - await server.plugins.install({ npmName: options.npmName, path: options.path }) + await server.plugins.install({ npmName: options.npmName, path: options.path, pluginVersion: options.pluginVersion }) } catch (err) { console.error('Cannot install plugin.', err) process.exit(-1) diff --git a/shared/extra-utils/server/plugins-command.ts b/shared/extra-utils/server/plugins-command.ts index b944475a2..9bf24afff 100644 --- a/shared/extra-utils/server/plugins-command.ts +++ b/shared/extra-utils/server/plugins-command.ts @@ -158,15 +158,16 @@ export class PluginsCommand extends AbstractCommand { install (options: OverrideCommandOptions & { path?: string npmName?: string + pluginVersion?: string }) { - const { npmName, path } = options + const { npmName, path, pluginVersion } = options const apiPath = '/api/v1/plugins/install' return this.postBodyRequest({ ...options, path: apiPath, - fields: { npmName, path }, + fields: { npmName, path, pluginVersion }, implicitToken: true, defaultExpectedStatus: HttpStatusCode.OK_200 }) diff --git a/shared/models/plugins/server/api/install-plugin.model.ts b/shared/models/plugins/server/api/install-plugin.model.ts index 5a268ebe1..a1d009a00 100644 --- a/shared/models/plugins/server/api/install-plugin.model.ts +++ b/shared/models/plugins/server/api/install-plugin.model.ts @@ -1,4 +1,5 @@ export interface InstallOrUpdatePlugin { npmName?: string + pluginVersion?: string path?: string } From b202d007cc553915b77ba9fa76b6d01fa678d845 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 30 Nov 2021 09:01:37 +0100 Subject: [PATCH 02/28] Bumped to version v4.0.0-rc.1 --- .github/workflows/codeql.yml | 71 ++++++++++++++++++++++ .github/workflows/codeql/codeql-config.yml | 4 ++ .github/workflows/stats.yml | 2 +- .github/workflows/test.yml | 2 +- 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/codeql/codeql-config.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..20803bd86 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,71 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ next ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ next ] + schedule: + - cron: '36 9 * * 5' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + config-file: ./.github/workflows/codeql/codeql-config.yml + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/codeql/codeql-config.yml b/.github/workflows/codeql/codeql-config.yml new file mode 100644 index 000000000..8b771ae99 --- /dev/null +++ b/.github/workflows/codeql/codeql-config.yml @@ -0,0 +1,4 @@ +name: "PeerTube CodeQL config" + +paths-ignore: + - server/tests diff --git a/.github/workflows/stats.yml b/.github/workflows/stats.yml index e211f6a3b..d6213deed 100644 --- a/.github/workflows/stats.yml +++ b/.github/workflows/stats.yml @@ -1,4 +1,4 @@ -name: "Stats" +name: Stats" on: push: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 78a9a28c0..0366ac49f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Test Suite +name: Test on: push: From f3fbbf01402fc7491e044f160edca06ef793eb50 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 30 Nov 2021 16:00:59 +0100 Subject: [PATCH 03/28] Add docker github action --- .github/workflows/docker.yml | 70 ++++++++++++++++++++++++++++++++++++ .github/workflows/stats.yml | 2 +- .gitlab-ci.yml | 44 ----------------------- 3 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..b4ff1a452 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,70 @@ +name: Docker + +on: + push: + branches: + - 'master' + schedule: + - cron: '0 3 * * *' + +jobs: + generate-matrix: + name: Generate matrix for Docker build + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: master + - name: Set matrix for build + id: set-matrix + run: | + # FIXME: https://github.com/actions/checkout/issues/290 + git fetch --force --tags + + one="{ \"file\": \"./support/docker/production/Dockerfile.bullseye\", \"ref\": \"develop\", \"tags\": \"chocobozzz/peertube-test:develop-bullseye\" }" + two="{ \"file\": \"./support/docker/production/Dockerfile.buster\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube-test:production-buster,chocobozzz/peertube-test:$(git describe --abbrev=0)-buster\" }" + three="{ \"file\": \"./support/docker/production/Dockerfile.nginx\", \"ref\": \"master\", \"tags\": \"chocobozzz/peertube-webserver-test:latest\" }" + + matrix="[$one,$two,$three]" + echo ::set-output name=matrix::{\"include\":$(echo $matrix)} + + docker: + runs-on: ubuntu-latest + + needs: generate-matrix + + strategy: + matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} + fail-fast: false + + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - + name: Checkout develop + uses: actions/checkout@v2 + with: + ref: ${{ matrix.ref }} + - + name: Docker build + uses: docker/build-push-action@v2 + with: + context: '.' + platforms: linux/amd64,linux/arm64 + push: true + file: ${{ matrix.file }} + tags: ${{ matrix.tags }} diff --git a/.github/workflows/stats.yml b/.github/workflows/stats.yml index d6213deed..e50c14720 100644 --- a/.github/workflows/stats.yml +++ b/.github/workflows/stats.yml @@ -1,4 +1,4 @@ -name: Stats" +name: Stats on: push: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad94c8cab..66c6df761 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,47 +38,3 @@ build-nightly: - eval `ssh-agent -s` - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then ssh-add <(echo "${DEPLOYEMENT_KEY}"); fi - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then scp ./peertube-nightly-* ${DEPLOYEMENT_USER}@${DEPLOYEMENT_HOST}:../../web/nightly; fi - -.docker: &docker - stage: docker-nightly - cache: {} - image: - name: gcr.io/kaniko-project/executor:debug - entrypoint: [""] - before_script: - - mkdir -p /kaniko/.docker - - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$CI_REGISTRY_AUTH\",\"email\":\"$CI_REGISTRY_EMAIL\"}}}" > /kaniko/.docker/config.json - script: - - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $DOCKERFILE --destination $DOCKER_IMAGE_NAME - -build-docker-develop: - <<: *docker - only: - - schedules - variables: - DOCKER_IMAGE_NAME: chocobozzz/peertube:develop-bullseye - DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.bullseye - -build-docker-webserver: - <<: *docker - only: - - schedules - variables: - DOCKER_IMAGE_NAME: chocobozzz/peertube-webserver - DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.nginx - -build-docker-tag: - <<: *docker - only: - - tags - variables: - DOCKER_IMAGE_NAME: chocobozzz/peertube:$CI_COMMIT_TAG-bullseye - DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.bullseye - -build-docker-master: - <<: *docker - only: - - master - variables: - DOCKER_IMAGE_NAME: chocobozzz/peertube:production-bullseye - DOCKERFILE: $CI_PROJECT_DIR/support/docker/production/Dockerfile.bullseye From 51e9e152f7df003c65c16f822669a0674efcaf03 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 1 Dec 2021 14:14:58 +0100 Subject: [PATCH 04/28] Build nightly using github action --- .github/actions/reusable-deploy/action.yml | 46 +++++++++++++ .../action.yml | 31 +++++++++ .../reusable-prepare-peertube-run/action.yml | 16 +++++ .github/workflows/benchmark.yml | 69 +++---------------- .github/workflows/codeql.yml | 2 +- .github/workflows/nightly.yml | 36 ++++++++++ .github/workflows/stats.yml | 48 +++---------- .github/workflows/test.yml | 25 +------ .gitlab-ci.yml | 40 ----------- support/doc/development/ci.md | 40 +++++++++++ 10 files changed, 191 insertions(+), 162 deletions(-) create mode 100644 .github/actions/reusable-deploy/action.yml create mode 100644 .github/actions/reusable-prepare-peertube-build/action.yml create mode 100644 .github/actions/reusable-prepare-peertube-run/action.yml create mode 100644 .github/workflows/nightly.yml delete mode 100644 .gitlab-ci.yml create mode 100644 support/doc/development/ci.md diff --git a/.github/actions/reusable-deploy/action.yml b/.github/actions/reusable-deploy/action.yml new file mode 100644 index 000000000..bc69a2e43 --- /dev/null +++ b/.github/actions/reusable-deploy/action.yml @@ -0,0 +1,46 @@ +name: "Reusable deploy on builds.joinpeertube.org" + +description: "Reusable deploy on builds.joinpeertube.org" + +inputs: + source: + required: true + description: "Source file/files/directory/directories to deploy" + destination: + required: true + description: "Destination directory on builds.joinpeertube.org" + knownHosts: + required: true + description: "Known hosts" + deployKey: + required: true + description: "Deploy key" + deployUser: + required: true + description: "Deploy user" + deployHost: + required: true + description: "Deploy host" + + +runs: + using: "composite" + + steps: + - name: "Deploy" + shell: bash + run: | + mkdir -p ~/.ssh + chmod 700 ~/.ssh + + echo "Adding ssh key to known hosts" + echo -e "${{ inputs.knownHosts }}" > ~/.ssh/known_hosts; + + eval `ssh-agent -s` + + echo "Adding ssh deploy key" + ssh-add <(echo "${{ inputs.deployKey }}"); + + echo "Uploading files" + + scp ${{ inputs.source }} ${{ inputs.deployUser }}@${{ inputs.deployHost }}:../../web/${{ inputs.destination }}; diff --git a/.github/actions/reusable-prepare-peertube-build/action.yml b/.github/actions/reusable-prepare-peertube-build/action.yml new file mode 100644 index 000000000..41ebf71c5 --- /dev/null +++ b/.github/actions/reusable-prepare-peertube-build/action.yml @@ -0,0 +1,31 @@ +name: "Reusable prepare PeerTube build" + +description: "Reusable prepare PeerTube build" + +inputs: + node-version: + required: true + description: 'NodeJS version' + +runs: + using: "composite" + + steps: + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: ${{ inputs.node-version }} + + - name: Cache Node.js modules + uses: actions/cache@v2 + with: + path: | + **/node_modules + key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.OS }}-node- + ${{ runner.OS }}- + + - name: Install dependencies + shell: bash + run: yarn install --frozen-lockfile diff --git a/.github/actions/reusable-prepare-peertube-run/action.yml b/.github/actions/reusable-prepare-peertube-run/action.yml new file mode 100644 index 000000000..1a6cd2cfd --- /dev/null +++ b/.github/actions/reusable-prepare-peertube-run/action.yml @@ -0,0 +1,16 @@ +name: "Reusable prepare PeerTube run" +description: "Reusable prepare PeerTube run" + +runs: + using: "composite" + + steps: + - name: Setup system dependencies + shell: bash + run: | + sudo apt-get install postgresql-client-common redis-tools parallel + wget --quiet --no-check-certificate "https://download.cpy.re/ffmpeg/ffmpeg-release-4.3.1-64bit-static.tar.xz" + tar xf ffmpeg-release-4.3.1-64bit-static.tar.xz + mkdir -p $HOME/bin + cp ffmpeg-*/{ffmpeg,ffprobe} $HOME/bin + echo "$HOME/bin" >> $GITHUB_PATH diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 86f675432..f02b88a42 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -29,48 +29,15 @@ jobs: env: PGUSER: peertube PGHOST: localhost - NODE_PENDING_JOB_WAIT: 500 steps: - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 + - uses: './.github/actions/reusable-prepare-peertube-build' with: node-version: '12.x' - - name: Setup system dependencies - run: | - sudo apt-get install postgresql-client-common redis-tools parallel - wget --quiet --no-check-certificate "https://download.cpy.re/ffmpeg/ffmpeg-release-4.3.1-64bit-static.tar.xz" - tar xf ffmpeg-release-4.3.1-64bit-static.tar.xz - mkdir -p $HOME/bin - cp ffmpeg-*/{ffmpeg,ffprobe} $HOME/bin - echo "$HOME/bin" >> $GITHUB_PATH - - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - path: | - **/node_modules - key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- - - - name: Cache fixtures - uses: actions/cache@v2 - with: - path: | - fixtures - key: ${{ runner.OS }}-fixtures-${{ matrix.test_suite }}-${{ hashFiles('fixtures/*') }} - restore-keys: | - ${{ runner.OS }}-fixtures-${{ matrix.test_suite }}- - ${{ runner.OS }}-fixtures- - ${{ runner.OS }}- - - - name: Install dependencies - run: yarn install --frozen-lockfile + - uses: './.github/actions/reusable-prepare-peertube-run' - name: Build run: | @@ -111,27 +78,11 @@ jobs: cat benchmark.json build-time.json startup-time.json - name: Upload benchmark result - env: - STATS_DEPLOYEMENT_KNOWN_HOSTS: ${{ secrets.STATS_DEPLOYEMENT_KNOWN_HOSTS }} - STATS_DEPLOYEMENT_KEY: ${{ secrets.STATS_DEPLOYEMENT_KEY }} - STATS_DEPLOYEMENT_USER: ${{ secrets.STATS_DEPLOYEMENT_USER }} - STATS_DEPLOYEMENT_HOST: ${{ secrets.STATS_DEPLOYEMENT_HOST }} - run: | - mkdir -p ~/.ssh - chmod 700 ~/.ssh - if [ ! -z ${STATS_DEPLOYEMENT_KNOWN_HOSTS+x} ]; then - echo "Adding ssh key to known hosts" - echo -e "${STATS_DEPLOYEMENT_KNOWN_HOSTS}" > ~/.ssh/known_hosts; - fi - - eval `ssh-agent -s` - - if [ ! -z ${STATS_DEPLOYEMENT_KEY+x} ]; then - echo "Adding ssh reployement key" - ssh-add <(echo "${STATS_DEPLOYEMENT_KEY}"); - fi - - if [ ! -z ${STATS_DEPLOYEMENT_KEY+x} ]; then - echo "Uploading files" - scp benchmark.json build-time.json startup-time.json ${STATS_DEPLOYEMENT_USER}@${STATS_DEPLOYEMENT_HOST}:../../web/peertube-stats; - fi + uses: './.github/actions/reusable-deploy.yml' + with: + source: benchmark.json build-time.json startup-time.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 }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 20803bd86..5c0c93886 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,7 +13,7 @@ name: "CodeQL" on: push: - branches: [ next ] + branches: [ develop, next ] pull_request: # The branches below must be a subset of the branches above branches: [ next ] diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..156b7143a --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,36 @@ +name: Nightly + +on: + push: + branches: + - 'next' + schedule: + - cron: '0 3 * * *' + +jobs: + + nightly: + runs-on: ubuntu-latest + + steps: + - + name: Checkout develop + uses: actions/checkout@v2 + with: + ref: next + + - uses: './.github/actions/reusable-prepare-peertube-build' + with: + node-version: '14.x' + + - name: Build + run: npm run nightly + + - uses: './.github/actions/reusable-deploy' + with: + source: ./peertube-nightly-* + destination: nightly-test + knownHosts: ${{ secrets.STATS_DEPLOYEMENT_KNOWN_HOSTS }} + deployKey: ${{ secrets.STATS_DEPLOYEMENT_KEY }} + deployUser: ${{ secrets.STATS_DEPLOYEMENT_USER }} + deployHost: ${{ secrets.STATS_DEPLOYEMENT_HOST }} diff --git a/.github/workflows/stats.yml b/.github/workflows/stats.yml index e50c14720..c87e6fb77 100644 --- a/.github/workflows/stats.yml +++ b/.github/workflows/stats.yml @@ -20,24 +20,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 + - uses: './.github/actions/reusable-prepare-peertube-build' with: node-version: '14.x' - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - path: | - **/node_modules - key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- - - - name: Install dependencies - run: yarn install --frozen-lockfile - - name: Angular bundlewatch uses: jackyef/bundlewatch-gh-action@master with: @@ -73,27 +59,11 @@ jobs: - name: Upload stats if: github.event_name != 'pull_request' - env: - STATS_DEPLOYEMENT_KNOWN_HOSTS: ${{ secrets.STATS_DEPLOYEMENT_KNOWN_HOSTS }} - STATS_DEPLOYEMENT_KEY: ${{ secrets.STATS_DEPLOYEMENT_KEY }} - STATS_DEPLOYEMENT_USER: ${{ secrets.STATS_DEPLOYEMENT_USER }} - STATS_DEPLOYEMENT_HOST: ${{ secrets.STATS_DEPLOYEMENT_HOST }} - run: | - mkdir -p ~/.ssh - chmod 700 ~/.ssh - if [ ! -z ${STATS_DEPLOYEMENT_KNOWN_HOSTS+x} ]; then - echo "Adding ssh key to known hosts" - echo -e "${STATS_DEPLOYEMENT_KNOWN_HOSTS}" > ~/.ssh/known_hosts; - fi - - eval `ssh-agent -s` - - if [ ! -z ${STATS_DEPLOYEMENT_KEY+x} ]; then - echo "Adding ssh reployement key" - ssh-add <(echo "${STATS_DEPLOYEMENT_KEY}"); - fi - - if [ ! -z ${STATS_DEPLOYEMENT_KEY+x} ]; then - echo "Uploading files" - scp lighthouse.json client-build-stats.json scc.json ${STATS_DEPLOYEMENT_USER}@${STATS_DEPLOYEMENT_HOST}:../../web/peertube-stats; - fi + 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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0366ac49f..030ec3790 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,29 +50,11 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Use Node.js - uses: actions/setup-node@v1 + - uses: './.github/actions/reusable-prepare-peertube-build' with: node-version: '12.x' - - name: Setup system dependencies - run: | - sudo apt-get install postgresql-client-common redis-tools parallel - wget --quiet --no-check-certificate "https://download.cpy.re/ffmpeg/ffmpeg-release-4.3.1-64bit-static.tar.xz" - tar xf ffmpeg-release-4.3.1-64bit-static.tar.xz - mkdir -p $HOME/bin - cp ffmpeg-*/{ffmpeg,ffprobe} $HOME/bin - echo "$HOME/bin" >> $GITHUB_PATH - - - name: Cache Node.js modules - uses: actions/cache@v2 - with: - path: | - **/node_modules - key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.OS }}-node- - ${{ runner.OS }}- + - uses: './.github/actions/reusable-prepare-peertube-run' - name: Cache fixtures uses: actions/cache@v2 @@ -85,9 +67,6 @@ jobs: ${{ runner.OS }}-fixtures- ${{ runner.OS }}- - - name: Install dependencies - run: yarn install --frozen-lockfile - - name: Set env test variable (schedule) if: github.event_name != 'schedule' run: | diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 66c6df761..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,40 +0,0 @@ -image: chocobozzz/peertube-ci:14 - -stages: - - clients - - docker-nightly - -cache: - key: yarn - paths: - - .yarn-cache - - cached-fixtures - -# build-openapi-clients: -# stage: clients -# only: -# refs: -# - master -# - schedules -# changes: -# - support/doc/api/openapi.yaml -# script: -# - apt-get update -qq -# - apt-get -yqqq install openjdk-8-jre -# - yarn install --pure-lockfile -# - scripts/openapi-peertube-version.sh -# - scripts/openapi-clients.sh - -build-nightly: - stage: docker-nightly - only: - - schedules - script: - - yarn install --pure-lockfile --cache-folder .yarn-cache - - npm run nightly - - mkdir "${HOME}/.ssh" - - chmod 700 "${HOME}/.ssh" - - if [ ! -z ${DEPLOYEMENT_KNOWN_HOSTS+x} ]; then echo -e "${DEPLOYEMENT_KNOWN_HOSTS}" > ${HOME}/.ssh/known_hosts; fi - - eval `ssh-agent -s` - - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then ssh-add <(echo "${DEPLOYEMENT_KEY}"); fi - - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then scp ./peertube-nightly-* ${DEPLOYEMENT_USER}@${DEPLOYEMENT_HOST}:../../web/nightly; fi diff --git a/support/doc/development/ci.md b/support/doc/development/ci.md new file mode 100644 index 000000000..7d6eef197 --- /dev/null +++ b/support/doc/development/ci.md @@ -0,0 +1,40 @@ +# Continuous integration + +PeerTube uses Github Actions as a CI platform. +CI tasks are described in `.github/workflows`. + +## benchmark.yml + +*Scheduled* + +Run various benchmarks (build, API etc) and upload results on https://builds.joinpeertube.org/peertube-stats/ to be publicly consumed. + +## codeql.yml + +*Scheduled, on push on develop and on pull request* + +Run CodeQL task to throw code security issues in Github. https://lgtm.com/projects/g/Chocobozzz/PeerTube can also be used. + +## docker.yml + +*Scheduled and on push on master* + +Build `chocobozzz/peertube-webserver:latest`, `chocobozzz/peertube:production-...`, `chocobozzz/peertube:v-...` (only latest PeerTube tag) and `chocobozzz/peertube:develop-...` Docker images. Scheduled to automatically upgrade image software (Debian security issues etc). + +## nightly.yml + +*Scheduled* + +Build PeerTube nightly build (`develop` branch) and upload the release on https://builds.joinpeertube.org/nightly. + +## stats.yml + +*On push on develop* + +Create various PeerTube stats (line of codes, build size, lighthouse report) and upload results on https://builds.joinpeertube.org/peertube-stats/ to be publicly consumed. + +## test.yml + +*Scheduled, on push and pull request* + +Run PeerTube lint and tests. From 22f25c740bf3eb24d9988ab6add8e1a6aec1b0bd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 2 Dec 2021 13:45:32 +0100 Subject: [PATCH 05/28] Recover HLS video with duration inconsistency With audio longer than video --- client/src/assets/player/p2p-media-loader/hls-plugin.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/assets/player/p2p-media-loader/hls-plugin.ts b/client/src/assets/player/p2p-media-loader/hls-plugin.ts index 71c31696a..2aa691f05 100644 --- a/client/src/assets/player/p2p-media-loader/hls-plugin.ts +++ b/client/src/assets/player/p2p-media-loader/hls-plugin.ts @@ -146,7 +146,9 @@ class Html5Hlsjs { } duration () { - return this._duration || this.videoElement.duration || 0 + if (!isNaN(this.videoElement.duration)) return this.videoElement.duration + + return this._duration || 0 } seekable () { @@ -366,6 +368,7 @@ class Html5Hlsjs { this.isLive = data.details.live this.dvrDuration = data.details.totalduration + this._duration = this.isLive ? Infinity : data.details.totalduration }) From 8406a9e8eec261e563d99c92f8a18b6bd3e46e0f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 2 Dec 2021 14:34:00 +0100 Subject: [PATCH 06/28] Fix forgot password button role --- client/src/app/+login/login.component.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/app/+login/login.component.html b/client/src/app/+login/login.component.html index 90eea1505..531b06dc9 100644 --- a/client/src/app/+login/login.component.html +++ b/client/src/app/+login/login.component.html @@ -48,7 +48,8 @@