mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-09 04:23:08 +02:00
Use generate-api-json for api.json diff GitHub comment (#12408)
* ci: use generate-api-json to get api.json changes * restore copying default.yml * refactor: get api.json with single workflow * ci: api.jsonのdiffをbackendが変更されたときのみ取るように
This commit is contained in:
parent
ed6f866a4f
commit
44a378c46e
1 changed files with 19 additions and 129 deletions
146
.github/workflows/get-api-diff.yml
vendored
146
.github/workflows/get-api-diff.yml
vendored
|
@ -6,9 +6,12 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- develop
|
- develop
|
||||||
|
paths:
|
||||||
|
- packages/backend/**
|
||||||
|
- .github/workflows/get-api-diff.yml
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
get-base:
|
get-from-misskey:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
@ -16,109 +19,20 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [20.5.1]
|
node-version: [20.5.1]
|
||||||
|
api-json-name: [api-base.json, api-head.json]
|
||||||
services:
|
include:
|
||||||
db:
|
- api-json-name: api-base.json
|
||||||
image: postgres:13
|
repo-name: ${{ github.event.pull_request.base.repo.full_name }}
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
env:
|
|
||||||
POSTGRES_DB: misskey
|
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust
|
|
||||||
POSTGRES_USER: example-misskey-user
|
|
||||||
POSTGRESS_PASS: example-misskey-pass
|
|
||||||
redis:
|
|
||||||
image: redis:7
|
|
||||||
ports:
|
|
||||||
- 6379:6379
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4.1.1
|
|
||||||
with:
|
|
||||||
repository: ${{ github.event.pull_request.base.repo.full_name }}
|
|
||||||
ref: ${{ github.base_ref }}
|
ref: ${{ github.base_ref }}
|
||||||
submodules: true
|
- api-json-name: api-head.json
|
||||||
- name: Install pnpm
|
repo-name: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
uses: pnpm/action-setup@v2
|
ref: ${{ github.head_ref }}
|
||||||
with:
|
|
||||||
version: 8
|
|
||||||
run_install: false
|
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
|
||||||
uses: actions/setup-node@v4.0.0
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node-version }}
|
|
||||||
cache: 'pnpm'
|
|
||||||
- run: corepack enable
|
|
||||||
- run: pnpm i --frozen-lockfile
|
|
||||||
- name: Check pnpm-lock.yaml
|
|
||||||
run: git diff --exit-code pnpm-lock.yaml
|
|
||||||
- name: Copy Configure
|
|
||||||
run: cp .config/example.yml .config/default.yml
|
|
||||||
- name: Build
|
|
||||||
run: pnpm build
|
|
||||||
- name : Migrate
|
|
||||||
run: pnpm migrate
|
|
||||||
- name: Launch misskey
|
|
||||||
run: |
|
|
||||||
screen -S misskey -dm pnpm run dev
|
|
||||||
sleep 30s
|
|
||||||
- name: Wait for Misskey to be ready
|
|
||||||
run: |
|
|
||||||
MAX_RETRIES=12
|
|
||||||
RETRY_DELAY=5
|
|
||||||
count=0
|
|
||||||
until $(curl --output /dev/null --silent --head --fail http://localhost:3000) || [[ $count -eq $MAX_RETRIES ]]; do
|
|
||||||
printf '.'
|
|
||||||
sleep $RETRY_DELAY
|
|
||||||
count=$((count + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $count -eq $MAX_RETRIES ]]; then
|
|
||||||
echo "Failed to connect to Misskey after $MAX_RETRIES attempts."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- id: fetch
|
|
||||||
name: Get api.json from Misskey
|
|
||||||
run: |
|
|
||||||
RESULT=$(curl --retry 5 --retry-delay 5 --retry-max-time 60 http://localhost:3000/api.json)
|
|
||||||
echo $RESULT > api-base.json
|
|
||||||
- name: Upload Artifact
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: api-artifact
|
|
||||||
path: api-base.json
|
|
||||||
- name: Kill Misskey Job
|
|
||||||
run: screen -S misskey -X quit
|
|
||||||
|
|
||||||
get-head:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
node-version: [20.5.1]
|
|
||||||
|
|
||||||
services:
|
|
||||||
db:
|
|
||||||
image: postgres:13
|
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
env:
|
|
||||||
POSTGRES_DB: misskey
|
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust
|
|
||||||
POSTGRES_USER: example-misskey-user
|
|
||||||
POSTGRESS_PASS: example-misskey-pass
|
|
||||||
redis:
|
|
||||||
image: redis:7
|
|
||||||
ports:
|
|
||||||
- 6379:6379
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4.1.1
|
- uses: actions/checkout@v4.1.1
|
||||||
with:
|
with:
|
||||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
repository: ${{ matrix.repo-name }}
|
||||||
ref: ${{ github.head_ref }}
|
ref: ${{ matrix.ref }}
|
||||||
submodules: true
|
submodules: true
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
uses: pnpm/action-setup@v2
|
uses: pnpm/action-setup@v2
|
||||||
|
@ -138,39 +52,15 @@ jobs:
|
||||||
run: cp .config/example.yml .config/default.yml
|
run: cp .config/example.yml .config/default.yml
|
||||||
- name: Build
|
- name: Build
|
||||||
run: pnpm build
|
run: pnpm build
|
||||||
- name : Migrate
|
- name: Generate API JSON
|
||||||
run: pnpm migrate
|
run: pnpm --filter backend generate-api-json
|
||||||
- name: Launch misskey
|
- name: Copy API.json
|
||||||
run: |
|
run: cp packages/backend/built/api.json ${{ matrix.api-json-name }}
|
||||||
screen -S misskey -dm pnpm run dev
|
|
||||||
sleep 30s
|
|
||||||
- name: Wait for Misskey to be ready
|
|
||||||
run: |
|
|
||||||
MAX_RETRIES=12
|
|
||||||
RETRY_DELAY=5
|
|
||||||
count=0
|
|
||||||
until $(curl --output /dev/null --silent --head --fail http://localhost:3000) || [[ $count -eq $MAX_RETRIES ]]; do
|
|
||||||
printf '.'
|
|
||||||
sleep $RETRY_DELAY
|
|
||||||
count=$((count + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $count -eq $MAX_RETRIES ]]; then
|
|
||||||
echo "Failed to connect to Misskey after $MAX_RETRIES attempts."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- id: fetch
|
|
||||||
name: Get api.json from Misskey
|
|
||||||
run: |
|
|
||||||
RESULT=$(curl --retry 5 --retry-delay 5 --retry-max-time 60 http://localhost:3000/api.json)
|
|
||||||
echo $RESULT > api-head.json
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: api-artifact
|
name: api-artifact
|
||||||
path: api-head.json
|
path: ${{ matrix.api-json-name }}
|
||||||
- name: Kill Misskey Job
|
|
||||||
run: screen -S misskey -X quit
|
|
||||||
|
|
||||||
save-pr-number:
|
save-pr-number:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
Loading…
Reference in a new issue