diff --git a/.github/workflows/check-cherrypick-js-autogen.yml b/.github/workflows/check-cherrypick-js-autogen.yml index d960785c09..f159ced2a1 100644 --- a/.github/workflows/check-cherrypick-js-autogen.yml +++ b/.github/workflows/check-cherrypick-js-autogen.yml @@ -5,24 +5,23 @@ on: branches: - master - develop + - improve-cherrypick-js-autogen-check paths: - packages/backend/** jobs: - check-cherrypick-js-autogen: + # pull_request_target safety: permissions: read-all, and there are no secrets used in this job + generate-cherrypick-js: runs-on: ubuntu-latest permissions: - pull-requests: write - - env: - api_json_name: "api-head.json" - + contents: read + if: ${{ github.event.pull_request.mergeable == null || github.event.pull_request.mergeable == true }} steps: - name: checkout uses: actions/checkout@v4.1.1 with: submodules: true - ref: ${{ github.event.pull_request.head.sha }} + ref: refs/pull/${{ github.event.pull_request.number }}/merge - name: setup pnpm uses: pnpm/action-setup@v3 @@ -39,79 +38,81 @@ jobs: - name: install dependencies run: pnpm i --frozen-lockfile - - name: wait get-api-diff - uses: lewagon/wait-on-check-action@v1.3.3 + # generate api.json + - name: Copy Config + run: cp .config/example.yml .config/default.yml + - name: Build + run: pnpm build + - name: Generate API JSON + run: pnpm --filter backend generate-api-json + + # build cherrypick js + - name: Build cherrypick-js + run: |- + cp packages/backend/built/api.json packages/cherrypick-js/generator/api.json + pnpm run --filter cherrypick-js-type-generator generate + + # packages/cherrypick-js/generator/built/autogen + - name: Upload Generated + uses: actions/upload-artifact@v4 with: - ref: ${{ github.event.pull_request.head.sha }} - check-regexp: get-from-cherrypick .+ - repo-token: ${{ secrets.GITHUB_TOKEN }} - wait-interval: 30 + name: generated-cherrypick-js + path: packages/cherrypick-js/generator/built/autogen - - name: Download artifact - uses: actions/github-script@v7.0.1 + # pull_request_target safety: permissions: read-all, and there are no secrets used in this job + get-actual-cherrypick-js: + runs-on: ubuntu-latest + permissions: + contents: read + if: ${{ github.event.pull_request.mergeable == null || github.event.pull_request.mergeable == true }} + steps: + - name: checkout + uses: actions/checkout@v4.1.1 with: - script: | - const fs = require('fs'); - - const workflows = await github.rest.actions.listWorkflowRunsForRepo({ - owner: context.repo.owner, - repo: context.repo.repo, - head_sha: `${{ github.event.pull_request.head.sha }}` - }).then(x => x.data.workflow_runs); - - console.log(workflows.map(x => ({name: x.name, title: x.display_title}))); - - const run_id = workflows.find(x => x.name.includes("Get api.json from CherryPick")).id; - - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: run_id, - }); - - let matchArtifacts = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name.startsWith("api-artifact-") || artifact.name == "api-artifact" - }); - - await Promise.all(matchArtifacts.map(async (artifact) => { - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: artifact.id, - archive_format: 'zip', - }); - await fs.promises.writeFile(`${process.env.GITHUB_WORKSPACE}/${artifact.name}.zip`, Buffer.from(download.data)); - })); - - - name: unzip artifacts - run: |- - find . -mindepth 1 -maxdepth 1 -type f -name '*.zip' -exec unzip {} -d . ';' - ls -la + submodules: true + ref: refs/pull/${{ github.event.pull_request.number }}/merge - - name: get head checksum - run: |- - checksum=$(realpath head_checksum) + - name: Upload From Merged + uses: actions/upload-artifact@v4 + with: + name: actual-cherrypick-js + path: packages/cherrypick-js/src/autogen - cd packages/cherrypick-js/src - find autogen -type f -exec sh -c 'echo $(sed -E "s/^\s+\*\s+generatedAt:.+$//" {} | sha256sum | cut -d" " -f 1) {}' \; > $checksum - cd ../../.. + # pull_request_target safety: nothing is cloned from repository + comment-cherrypick-js-autogen: + runs-on: ubuntu-latest + needs: [generate-cherrypick-js, get-actual-cherrypick-js] + permissions: + pull-requests: write + steps: + - name: download generated-cherrypick-js + uses: actions/download-artifact@v4 + with: + name: generated-cherrypick-js + path: cherrypick-js-generated - - name: build autogen - run: |- - checksum=$(realpath ${api_json_name}_checksum) - mv $api_json_name packages/cherrypick-js/generator/api.json + - name: download actual-cherrypick-js + uses: actions/download-artifact@v4 + with: + name: actual-cherrypick-js + path: cherrypick-js-actual + + - name: check cherrypick-js changes + id: check-changes + run: | + diff -r -u --label=generated --label=on-tree ./cherrypick-js-generated ./cherrypick-js-actual > cherrypick-js.diff || true - cd packages/cherrypick-js/generator - pnpm run generate - cd built - find autogen -type f -exec sh -c 'echo $(sed -E "s/^\s+\*\s+generatedAt:.+$//" {} | sha256sum | cut -d" " -f 1) {}' \; > $checksum - cd ../../../.. + if [ -s cherrypick-js.diff ]; then + echo "changes=true" >> $GITHUB_OUTPUT + else + echo "changes=false" >> $GITHUB_OUTPUT + fi - - name: check update for type definitions - run: diff head_checksum ${api_json_name}_checksum + - name: Print full diff + run: cat ./cherrypick-js.diff - name: send message - if: failure() + if: steps.check-changes.outputs.changes == 'true' uses: thollander/actions-comment-pull-request@v2 with: comment_tag: check-cherrypick-js-autogen @@ -125,7 +126,7 @@ jobs: ``` - name: send message - if: success() + if: steps.check-changes.outputs.changes == 'false' uses: thollander/actions-comment-pull-request@v2 with: comment_tag: check-cherrypick-js-autogen diff --git a/.github/workflows/deploy-test-environment.yml b/.github/workflows/deploy-test-environment.yml index 77cdcfaf88..66b15beb91 100644 --- a/.github/workflows/deploy-test-environment.yml +++ b/.github/workflows/deploy-test-environment.yml @@ -50,12 +50,9 @@ jobs: - name: Get PR ref id: get-ref - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - PR_NUMBER=$(jq --raw-output .issue.number $GITHUB_EVENT_PATH) - PR_REF=$(gh pr view $PR_NUMBER --json headRefName -q '.headRefName') - echo "pr-ref=$PR_REF" > $GITHUB_OUTPUT + PR_REF="refs/pull/${{ github.event.issue.number }}/head" + echo "pr-ref=$PR_REF" >> $GITHUB_OUTPUT - name: Extract wait time id: get-wait-time diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fc51a8d5f7..621094fd61 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -92,6 +92,6 @@ jobs: - run: pnpm i --frozen-lockfile - run: pnpm --filter cherrypick-js run build if: ${{ matrix.workspace == 'backend' }} - - run: pnpm --filter misskey-reversi run build:tsc + - run: pnpm --filter misskey-reversi run build if: ${{ matrix.workspace == 'backend' }} - run: pnpm --filter ${{ matrix.workspace }} run typecheck diff --git a/.github/workflows/storybook.yml b/.github/workflows/storybook.yml index 245a9495da..293af1f6ec 100644 --- a/.github/workflows/storybook.yml +++ b/.github/workflows/storybook.yml @@ -87,12 +87,13 @@ jobs: if [ "$CHROMATIC_PARAMETER" = " --skip" ]; then echo "skip=true" >> $GITHUB_OUTPUT fi - BRANCH="${{ github.event.pull_request.head.user.login }}:${{ github.event.pull_request.head.ref }}" - if [ "$BRANCH" = "kokonect-link:${{ github.event.pull_request.head.ref }}" ]; then - BRANCH="${{ github.event.pull_request.head.ref }}" + BRANCH="${{ github.event.pull_request.head.user.login }}:$HEAD_REF" + if [ "$BRANCH" = "kokonect-link:$HEAD_REF" ]; then + BRANCH="$HEAD_REF" fi pnpm --filter frontend chromatic --exit-once-uploaded -d storybook-static --branch-name $BRANCH $(echo "$CHROMATIC_PARAMETER") env: + HEAD_REF: ${{ github.event.pull_request.head.ref }} CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} - name: Notify that Chromatic detects changes uses: actions/github-script@v7.0.1 diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index faea72cef1..5495dac98e 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -45,6 +45,8 @@ jobs: with: version: 8 run_install: false + - name: Install FFmpeg + uses: FedericoCarboni/setup-ffmpeg@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4.0.2 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bd93080f4..b1af78c070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,70 @@ - diff --git a/packages/frontend/src/components/MkMediaVideo.vue b/packages/frontend/src/components/MkMediaVideo.vue index 2cd259d76d..168345f63f 100644 --- a/packages/frontend/src/components/MkMediaVideo.vue +++ b/packages/frontend/src/components/MkMediaVideo.vue @@ -6,6 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only