Skip to content

Commit

Permalink
Merge branch 'main.pooza' into daisskey
Browse files Browse the repository at this point in the history
  • Loading branch information
pooza committed May 15, 2024
2 parents 41528fd + b22e60a commit 9987051
Show file tree
Hide file tree
Showing 340 changed files with 23,751 additions and 15,591 deletions.
2 changes: 1 addition & 1 deletion .config/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# Option 3: If neither of the above applies to you.
# (In this case, the source code should be published
# on the Misskey interface. IT IS NOT ENOUGH TO
# DISCLOSE THE SOURCE CODE WEHN A USER REQUESTS IT BY
# DISCLOSE THE SOURCE CODE WHEN A USER REQUESTS IT BY
# E-MAIL OR OTHER MEANS. If you are not satisfied
# with this, it is recommended that you read the
# license again carefully. Anyway, enabling this
Expand Down
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"version": "8.9.2"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "20.10.0"
"version": "20.12.2"
}
},
"forwardPorts": [3000],
Expand All @@ -19,7 +19,6 @@
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"Vue.volar",
"Vue.vscode-typescript-vue-plugin",
"Orta.vscode-jest",
"dbaeumer.vscode-eslint",
"mrmlnc.vscode-json5"
Expand Down
145 changes: 73 additions & 72 deletions .github/workflows/check-misskey-js-autogen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,28 @@ on:
branches:
- master
- develop
- improve-misskey-js-autogen-check
paths:
- packages/backend/**

jobs:
check-misskey-js-autogen:
# pull_request_target safety: permissions: read-all, and there are no secrets used in this job
generate-misskey-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/[email protected]
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
with:
version: 8
version: 9

- name: setup node
id: setup-node
Expand All @@ -39,79 +38,81 @@ jobs:
- name: install dependencies
run: pnpm i --frozen-lockfile

- name: wait get-api-diff
uses: lewagon/[email protected]
# 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 misskey js
- name: Build misskey-js
run: |-
cp packages/backend/built/api.json packages/misskey-js/generator/api.json
pnpm run --filter misskey-js-type-generator generate
# packages/misskey-js/generator/built/autogen
- name: Upload Generated
uses: actions/upload-artifact@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
check-regexp: get-from-misskey .+
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 30
name: generated-misskey-js
path: packages/misskey-js/generator/built/autogen

- name: Download artifact
uses: actions/[email protected]
# pull_request_target safety: permissions: read-all, and there are no secrets used in this job
get-actual-misskey-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/[email protected]
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 Misskey")).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-misskey-js
path: packages/misskey-js/src/autogen

cd packages/misskey-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-misskey-js-autogen:
runs-on: ubuntu-latest
needs: [generate-misskey-js, get-actual-misskey-js]
permissions:
pull-requests: write
steps:
- name: download generated-misskey-js
uses: actions/download-artifact@v4
with:
name: generated-misskey-js
path: misskey-js-generated

- name: build autogen
run: |-
checksum=$(realpath ${api_json_name}_checksum)
mv $api_json_name packages/misskey-js/generator/api.json
- name: download actual-misskey-js
uses: actions/download-artifact@v4
with:
name: actual-misskey-js
path: misskey-js-actual

- name: check misskey-js changes
id: check-changes
run: |
diff -r -u --label=generated --label=on-tree ./misskey-js-generated ./misskey-js-actual > misskey-js.diff || true
cd packages/misskey-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 misskey-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 ./misskey-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-misskey-js-autogen
Expand All @@ -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-misskey-js-autogen
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/check-spdx-license-id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Check SPDX-License-Identifier

on:
push:
branches:
- master
- develop
pull_request:

jobs:
check-spdx-license-id:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Check
run: |
counter=0
search() {
local directory="$1"
find "$directory" -type f \
'(' \
-name "*.cjs" -and -not -name '*.config.cjs' -o \
-name "*.html" -o \
-name "*.js" -and -not -name '*.config.js' -o \
-name "*.mjs" -and -not -name '*.config.mjs' -o \
-name "*.scss" -o \
-name "*.ts" -and -not -name '*.config.ts' -o \
-name "*.vue" \
')' -and \
-not -name '*eslint*'
}
check() {
local file="$1"
if ! (
grep -q "SPDX-FileCopyrightText: syuilo and misskey-project" "$file" ||
grep -q "SPDX-License-Identifier: AGPL-3.0-only" "$file"
); then
echo "Missing: $file"
((counter++))
fi
}
directories=(
"cypress/e2e"
"packages/backend/migration"
"packages/backend/src"
"packages/backend/test"
"packages/frontend/.storybook"
"packages/frontend/@types"
"packages/frontend/lib"
"packages/frontend/public"
"packages/frontend/src"
"packages/frontend/test"
"packages/misskey-bubble-game/src"
"packages/misskey-reversi/src"
"packages/sw/src"
"scripts"
)
for directory in "${directories[@]}"; do
for file in $(search $directory); do
check "$file"
done
done
if [ $counter -gt 0 ]; then
echo "SPDX-License-Identifier is missing in $counter files."
exit 1
else
echo "SPDX-License-Identifier is certainly described in all target files!"
exit 0
fi
7 changes: 2 additions & 5 deletions .github/workflows/deploy-test-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/get-api-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

strategy:
matrix:
node-version: [20.10.0]
node-version: [20.12.2]
api-json-name: [api-base.json, api-head.json]
include:
- api-json-name: api-base.json
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8
version: 9
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
submodules: true
- uses: pnpm/action-setup@v3
with:
version: 8
version: 9
run_install: false
- uses: actions/[email protected]
with:
Expand All @@ -56,7 +56,7 @@ jobs:
submodules: true
- uses: pnpm/action-setup@v3
with:
version: 7
version: 9
run_install: false
- uses: actions/[email protected]
with:
Expand All @@ -82,7 +82,7 @@ jobs:
submodules: true
- uses: pnpm/action-setup@v3
with:
version: 7
version: 9
run_install: false
- uses: actions/[email protected]
with:
Expand All @@ -92,6 +92,6 @@ jobs:
- run: pnpm i --frozen-lockfile
- run: pnpm --filter misskey-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
4 changes: 2 additions & 2 deletions .github/workflows/on-release-created.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
node-version: [20.10.0]
node-version: [20.12.2]

steps:
- uses: actions/[email protected]
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8
version: 9
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
Expand Down
Loading

0 comments on commit 9987051

Please sign in to comment.