2021-09-03 11:13:33 +00:00
|
|
|
# Listens for new PR comments containing !pp check [id], and runs a diffcalc comparison against master.
|
|
|
|
# Usage:
|
|
|
|
# !pp check 0 | Runs only the osu! ruleset.
|
|
|
|
# !pp check 0 2 | Runs only the osu! and catch rulesets.
|
|
|
|
#
|
|
|
|
|
2021-09-20 17:47:27 +00:00
|
|
|
name: Difficulty Calculation
|
2021-09-03 08:56:56 +00:00
|
|
|
on:
|
|
|
|
issue_comment:
|
|
|
|
types: [ created ]
|
|
|
|
|
|
|
|
env:
|
|
|
|
CONCURRENCY: 4
|
|
|
|
ALLOW_DOWNLOAD: 1
|
|
|
|
SAVE_DOWNLOADED: 1
|
2021-09-20 15:37:12 +00:00
|
|
|
SKIP_INSERT_ATTRIBUTES: 1
|
2021-09-03 08:56:56 +00:00
|
|
|
|
|
|
|
jobs:
|
2021-09-20 17:27:21 +00:00
|
|
|
metadata:
|
2021-09-20 17:47:27 +00:00
|
|
|
name: Check for requests
|
2021-09-20 17:27:21 +00:00
|
|
|
runs-on: self-hosted
|
|
|
|
if: github.event.issue.pull_request && contains(github.event.comment.body, '!pp check') && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
|
|
|
|
outputs:
|
|
|
|
matrix: ${{ steps.generate-matrix.outputs.matrix }}
|
|
|
|
continue: ${{ steps.generate-matrix.outputs.continue }}
|
|
|
|
steps:
|
2021-09-20 17:47:27 +00:00
|
|
|
- name: Construct build matrix
|
2021-09-20 17:27:21 +00:00
|
|
|
id: generate-matrix
|
|
|
|
run: |
|
2021-09-20 17:54:37 +00:00
|
|
|
if [[ "${{ github.event.comment.body }}" =~ "osu" ]] ; then
|
2021-09-20 17:27:21 +00:00
|
|
|
MATRIX_PROJECTS_JSON+='{ "name": "osu", "id": 0 },'
|
|
|
|
fi
|
2021-09-20 17:54:37 +00:00
|
|
|
if [[ "${{ github.event.comment.body }}" =~ "taiko" ]] ; then
|
2021-09-20 17:27:21 +00:00
|
|
|
MATRIX_PROJECTS_JSON+='{ "name": "taiko", "id": 1 },'
|
|
|
|
fi
|
2021-09-20 17:54:37 +00:00
|
|
|
if [[ "${{ github.event.comment.body }}" =~ "catch" ]] ; then
|
2021-09-20 17:27:21 +00:00
|
|
|
MATRIX_PROJECTS_JSON+='{ "name": "catch", "id": 2 },'
|
|
|
|
fi
|
2021-09-20 17:54:37 +00:00
|
|
|
if [[ "${{ github.event.comment.body }}" =~ "mania" ]] ; then
|
2021-09-20 17:27:21 +00:00
|
|
|
MATRIX_PROJECTS_JSON+='{ "name": "mania", "id": 3 },'
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${MATRIX_PROJECTS_JSON}" != "" ]]; then
|
|
|
|
MATRIX_JSON="{ \"ruleset\": [ ${MATRIX_PROJECTS_JSON} ] }"
|
|
|
|
echo "${MATRIX_JSON}"
|
|
|
|
CONTINUE="yes"
|
|
|
|
else
|
|
|
|
CONTINUE="no"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "::set-output name=continue::${CONTINUE}"
|
|
|
|
echo "::set-output name=matrix::${MATRIX_JSON}"
|
2021-09-03 08:56:56 +00:00
|
|
|
diffcalc:
|
2021-09-20 17:47:27 +00:00
|
|
|
name: Run
|
2021-09-17 10:47:41 +00:00
|
|
|
runs-on: self-hosted
|
2021-10-03 13:32:46 +00:00
|
|
|
timeout-minutes: 1440
|
2021-09-20 17:27:21 +00:00
|
|
|
if: needs.metadata.outputs.continue == 'yes'
|
|
|
|
needs: metadata
|
2021-09-03 08:56:56 +00:00
|
|
|
strategy:
|
2021-09-20 17:27:21 +00:00
|
|
|
matrix: ${{ fromJson(needs.metadata.outputs.matrix) }}
|
2021-09-03 08:56:56 +00:00
|
|
|
steps:
|
|
|
|
- name: Verify MySQL connection from host
|
|
|
|
run: |
|
2021-09-20 16:14:33 +00:00
|
|
|
mysql -e "SHOW DATABASES"
|
2021-09-03 08:56:56 +00:00
|
|
|
|
2021-09-17 18:57:25 +00:00
|
|
|
- name: Drop previous databases
|
|
|
|
run: |
|
2021-09-20 16:14:33 +00:00
|
|
|
for db in osu_master osu_pr
|
|
|
|
do
|
|
|
|
mysql -e "DROP DATABASE IF EXISTS $db"
|
|
|
|
done
|
2021-09-17 18:57:25 +00:00
|
|
|
|
2021-09-03 08:56:56 +00:00
|
|
|
- name: Create directory structure
|
|
|
|
run: |
|
|
|
|
mkdir -p $GITHUB_WORKSPACE/master/
|
|
|
|
mkdir -p $GITHUB_WORKSPACE/pr/
|
|
|
|
|
2021-09-21 16:13:47 +00:00
|
|
|
- name: Get upstream branch # https://akaimo.hatenablog.jp/entry/2020/05/16/101251
|
|
|
|
id: upstreambranch
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=branchname::$(curl -H "Authorization: token ${GITHUB_TOKEN}" ${{ github.event.issue.pull_request.url }} | jq '.head.ref' | sed 's/\"//g')"
|
2021-09-21 16:28:17 +00:00
|
|
|
echo "::set-output name=repo::$(curl -H "Authorization: token ${GITHUB_TOKEN}" ${{ github.event.issue.pull_request.url }} | jq '.head.repo.full_name' | sed 's/\"//g')"
|
2021-09-21 16:13:47 +00:00
|
|
|
|
2021-09-03 08:56:56 +00:00
|
|
|
# Checkout osu
|
|
|
|
- name: Checkout osu (master)
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
path: 'master/osu'
|
|
|
|
- name: Checkout osu (pr)
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
path: 'pr/osu'
|
2021-09-21 16:29:56 +00:00
|
|
|
repository: ${{ steps.upstreambranch.outputs.repo }}
|
2021-09-21 16:13:47 +00:00
|
|
|
ref: ${{ steps.upstreambranch.outputs.branchname }}
|
2021-09-03 08:56:56 +00:00
|
|
|
|
|
|
|
- name: Checkout osu-difficulty-calculator (master)
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
2021-09-21 05:23:44 +00:00
|
|
|
repository: ppy/osu-difficulty-calculator
|
2021-09-03 08:56:56 +00:00
|
|
|
path: 'master/osu-difficulty-calculator'
|
|
|
|
- name: Checkout osu-difficulty-calculator (pr)
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
2021-09-21 05:23:44 +00:00
|
|
|
repository: ppy/osu-difficulty-calculator
|
2021-09-03 08:56:56 +00:00
|
|
|
path: 'pr/osu-difficulty-calculator'
|
|
|
|
|
|
|
|
- name: Install .NET 5.0.x
|
|
|
|
uses: actions/setup-dotnet@v1
|
|
|
|
with:
|
|
|
|
dotnet-version: "5.0.x"
|
|
|
|
|
|
|
|
# Sanity checks to make sure diffcalc is not run when incompatible.
|
|
|
|
- name: Build diffcalc (master)
|
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE/master/osu-difficulty-calculator
|
|
|
|
./UseLocalOsu.sh
|
|
|
|
dotnet build
|
|
|
|
- name: Build diffcalc (pr)
|
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE/pr/osu-difficulty-calculator
|
|
|
|
./UseLocalOsu.sh
|
|
|
|
dotnet build
|
|
|
|
|
|
|
|
- name: Download + import data
|
|
|
|
run: |
|
2021-09-14 03:18:19 +00:00
|
|
|
PERFORMANCE_DATA_NAME=$(curl https://data.ppy.sh/ | grep performance_${{ matrix.ruleset.name }}_top_1000 | tail -1 | awk -F "\"" '{print $2}' | sed 's/\.tar\.bz2//g')
|
2021-09-03 09:10:16 +00:00
|
|
|
BEATMAPS_DATA_NAME=$(curl https://data.ppy.sh/ | grep osu_files | tail -1 | awk -F "\"" '{print $2}' | sed 's/\.tar\.bz2//g')
|
2021-09-03 08:56:56 +00:00
|
|
|
|
|
|
|
# Set env variable for further steps.
|
|
|
|
echo "BEATMAPS_PATH=$GITHUB_WORKSPACE/$BEATMAPS_DATA_NAME" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
cd $GITHUB_WORKSPACE
|
|
|
|
|
2021-09-20 16:44:07 +00:00
|
|
|
echo "Downloading database dump $PERFORMANCE_DATA_NAME.."
|
|
|
|
wget -q -nc https://data.ppy.sh/$PERFORMANCE_DATA_NAME.tar.bz2
|
|
|
|
echo "Extracting.."
|
2021-09-03 08:56:56 +00:00
|
|
|
tar -xf $PERFORMANCE_DATA_NAME.tar.bz2
|
2021-09-20 16:44:07 +00:00
|
|
|
|
|
|
|
echo "Downloading beatmap dump $BEATMAPS_DATA_NAME.."
|
2021-09-20 16:44:54 +00:00
|
|
|
wget -q -nc https://data.ppy.sh/$BEATMAPS_DATA_NAME.tar.bz2
|
2021-09-20 16:44:07 +00:00
|
|
|
echo "Extracting.."
|
2021-09-03 08:56:56 +00:00
|
|
|
tar -xf $BEATMAPS_DATA_NAME.tar.bz2
|
|
|
|
|
2021-09-20 16:14:33 +00:00
|
|
|
cd $PERFORMANCE_DATA_NAME
|
|
|
|
|
|
|
|
for db in osu_master osu_pr
|
|
|
|
do
|
|
|
|
echo "Setting up database $db.."
|
|
|
|
|
|
|
|
mysql -e "CREATE DATABASE $db"
|
2021-09-03 08:56:56 +00:00
|
|
|
|
2021-09-20 16:44:07 +00:00
|
|
|
echo "Importing beatmaps.."
|
2021-09-20 16:14:33 +00:00
|
|
|
cat osu_beatmaps.sql | mysql $db
|
2021-09-20 16:44:07 +00:00
|
|
|
echo "Importing beatmapsets.."
|
2021-09-20 16:14:33 +00:00
|
|
|
cat osu_beatmapsets.sql | mysql $db
|
2021-09-03 08:56:56 +00:00
|
|
|
|
2021-09-20 16:44:07 +00:00
|
|
|
echo "Creating table structure.."
|
|
|
|
mysql $db -e 'CREATE TABLE `osu_beatmap_difficulty` (
|
2021-09-20 16:14:33 +00:00
|
|
|
`beatmap_id` int unsigned NOT NULL,
|
2021-09-20 16:44:07 +00:00
|
|
|
`mode` tinyint NOT NULL DEFAULT 0,
|
2021-09-20 16:14:33 +00:00
|
|
|
`mods` int unsigned NOT NULL,
|
|
|
|
`diff_unified` float NOT NULL,
|
|
|
|
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
PRIMARY KEY (`beatmap_id`,`mode`,`mods`),
|
|
|
|
KEY `diff_sort` (`mode`,`mods`,`diff_unified`)
|
2021-09-20 16:44:07 +00:00
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;'
|
2021-09-20 16:14:33 +00:00
|
|
|
done
|
2021-09-03 08:56:56 +00:00
|
|
|
|
|
|
|
- name: Run diffcalc (master)
|
|
|
|
env:
|
|
|
|
DB_NAME: osu_master
|
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE/master/osu-difficulty-calculator/osu.Server.DifficultyCalculator
|
|
|
|
dotnet run -c:Release -- all -m ${{ matrix.ruleset.id }} -ac -c ${{ env.CONCURRENCY }}
|
|
|
|
- name: Run diffcalc (pr)
|
|
|
|
env:
|
|
|
|
DB_NAME: osu_pr
|
|
|
|
run: |
|
|
|
|
cd $GITHUB_WORKSPACE/pr/osu-difficulty-calculator/osu.Server.DifficultyCalculator
|
|
|
|
dotnet run -c:Release -- all -m ${{ matrix.ruleset.id }} -ac -c ${{ env.CONCURRENCY }}
|
|
|
|
|
|
|
|
- name: Print diffs
|
|
|
|
run: |
|
2021-09-20 16:14:33 +00:00
|
|
|
mysql -e "
|
2021-09-03 08:56:56 +00:00
|
|
|
SELECT
|
|
|
|
m.beatmap_id,
|
|
|
|
m.mods,
|
2021-09-16 05:24:30 +00:00
|
|
|
b.filename,
|
2021-09-03 10:23:55 +00:00
|
|
|
m.diff_unified as 'sr_master',
|
|
|
|
p.diff_unified as 'sr_pr',
|
|
|
|
(p.diff_unified - m.diff_unified) as 'diff'
|
2021-09-03 08:56:56 +00:00
|
|
|
FROM osu_master.osu_beatmap_difficulty m
|
|
|
|
JOIN osu_pr.osu_beatmap_difficulty p
|
|
|
|
ON m.beatmap_id = p.beatmap_id
|
|
|
|
AND m.mode = p.mode
|
|
|
|
AND m.mods = p.mods
|
2021-09-16 05:24:30 +00:00
|
|
|
JOIN osu_pr.osu_beatmaps b
|
|
|
|
ON b.beatmap_id = p.beatmap_id
|
2021-09-03 08:56:56 +00:00
|
|
|
WHERE abs(m.diff_unified - p.diff_unified) > 0.1
|
|
|
|
ORDER BY abs(m.diff_unified - p.diff_unified)
|
2021-09-06 07:53:09 +00:00
|
|
|
DESC
|
|
|
|
LIMIT 10000;"
|
2021-09-03 08:56:56 +00:00
|
|
|
|
2021-09-17 18:49:30 +00:00
|
|
|
# Todo: Run ppcalc
|