Skip to content

Commit 77f3b18

Browse files
committed
WIP: CI
1 parent 0e589cf commit 77f3b18

File tree

5 files changed

+209
-3
lines changed

5 files changed

+209
-3
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
2+
3+
name: Beat Analyzer
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
branch:
9+
type: string
10+
required: true
11+
previous_snapshot:
12+
type: string
13+
default: ""
14+
publish_report:
15+
type: boolean
16+
default: false
17+
outputs:
18+
report:
19+
value: ${{ jobs.report.outputs.report }}
20+
snapshot:
21+
value: ${{ jobs.report.outputs.snapshot }}
22+
23+
permissions:
24+
contents: read # to fetch code (actions/checkout)
25+
26+
jobs:
27+
report:
28+
name: Generate the beat analyzer report
29+
runs-on: ubuntu-latest
30+
outputs:
31+
report: ${{ steps.benchmark.outputs.report }}
32+
snapshot: ${{ steps.benchmark.outputs.snapshot }}
33+
steps:
34+
- name: "Check out repository"
35+
uses: actions/checkout@v6
36+
with:
37+
ref: ${{ inputs.branch }}
38+
39+
- name: Install build dependencies
40+
run: tools/debian_buildenv.sh setup
41+
42+
- name: Create build directory
43+
run: mkdir build
44+
45+
- name: "Set up GitHub cache for dataset"
46+
uses: actions/cache@v4
47+
with:
48+
path: |
49+
/tmp/benchmark
50+
build
51+
key: benchmark-analyzer-data-${{ inputs.branch }}
52+
restore-keys: |
53+
benchmark-analyzer-data-${{ inputs.branch }}
54+
benchmark-analyzer-data
55+
56+
- name: Configure
57+
run: |
58+
cmake \
59+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
60+
-DQT6=ON \
61+
-DOPTIMIZE=portable \
62+
-DBATTERY=OFF \
63+
-DBROADCAST=OFF \
64+
-DBULK=OFF \
65+
-DHID=OFF \
66+
-DLILV=ON \
67+
-DOPUS=ON \
68+
-DQTKEYCHAIN=OFF \
69+
-DVINYLCONTROL=OFF \
70+
-DFFMPEG=ON \
71+
-DKEYFINDER=ON \
72+
-DLOCALECOMPARE=ON \
73+
-DMAD=ON \
74+
-DMODPLUG=ON \
75+
-DWAVPACK=ON \
76+
..
77+
env:
78+
LD: clang++
79+
CC: clang
80+
CXX: clang++
81+
working-directory: build
82+
- name: Build
83+
run: cmake --build . -j $(nproc) --target mixxx-test
84+
working-directory: build
85+
- name: "Run benchmark"
86+
id: benchmark
87+
run: |
88+
PREVIOUS_SNAPSHOT_ARG=''
89+
if [ -n "PREVIOUS_SNAPSHOT"]; then
90+
echo "${PREVIOUS_SNAPSHOT}" > /tmp/previous_snapshot.json
91+
PREVIOUS_SNAPSHOT_ARG='/tmp/previous_snapshot.json'
92+
fi
93+
mkdir report
94+
python3 tools/analyzer_benchmark.py ./tools/analyzer_free_dataset.csv $GITHUB_STEP_SUMMARY report/snapshot.json $PREVIOUS_SNAPSHOT_ARG
95+
echo "report=$(base64 -w0 $GITHUB_STEP_SUMMARY)" >> $GITHUB_OUTPUT
96+
echo "snapshot=$(base64 -w0 /tmp/snapshot.json)" >> $GITHUB_OUTPUT
97+
cp $GITHUB_STEP_SUMMARY report/report.md
98+
env:
99+
PREVIOUS_SNAPSHOT: ${{ inputs.previous_snapshot }}
100+
DOWNLOAD_FOLDER: /tmp/benchmark
101+
MIXXX_TEST_PATH: ./build/mixxx-test
102+
- name: "Upload report"
103+
if: ${{ inputs.publish_report }}
104+
uses: actions/upload-artifact@v5.0.0
105+
with:
106+
name: Beat analyzer report
107+
path: report/

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
22

3-
name: Build
3+
name: Benchmark
44

55
on:
66
workflow_call:

.github/workflows/pr-command.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,98 @@ jobs:
5050
uses: ./.github/workflows/benchmark.yml
5151
with:
5252
branch: ${{ github.head_ref || github.ref_name }}
53+
54+
fetch_beat_analyzer_report:
55+
name: Fetch previous beat analyzer report
56+
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/beat-analyzer')
57+
runs-on: ubuntu-latest
58+
outputs:
59+
previous_snapshot: ${{ steps.report.outputs.previous_snapshot }}
60+
steps:
61+
- name: Fetch latest report
62+
uses: actions/github-script@v6
63+
id: resolve
64+
with:
65+
script: |
66+
// Check if the issue is associated with a PR
67+
if (!context.payload.issue.pull_request) {
68+
console.log("This issue is not associated with a pull request.");
69+
return false;
70+
}
71+
72+
// Fetch PR details to get the branch
73+
const prResponse = await github.rest.pulls.get({
74+
owner: context.repo.owner,
75+
repo: context.repo.repo,
76+
pull_number: context.payload.issue.number,
77+
});
78+
const branch = prResponse.data.head.ref;
79+
console.log(`Resolved branch: ${branch}`);
80+
81+
const { data: workflow_runs } = await github.rest.actions.listWorkflowRuns({
82+
owner: context.repo.owner,
83+
repo: context.repo.repo,
84+
workflow_id: 'release.yml',
85+
branch: branch,
86+
per_page: 1,
87+
});
88+
89+
if (workflow_runs.workflow_runs.length === 0) {
90+
core.setFailed('No workflow runs found.');
91+
return false;
92+
}
93+
94+
const latest_run_id = workflow_runs.workflow_runs[0].id;
95+
96+
const { data: artifacts } = await github.rest.actions.listWorkflowRunArtifacts({
97+
owner: context.repo.owner,
98+
repo: context.repo.repo,
99+
run_id: latest_run_id,
100+
});
101+
102+
if (artifacts.artifacts.length === 0) {
103+
console.log('No artifacts found.');
104+
return false;
105+
}
106+
107+
// Filter artifacts by name
108+
const targetArtifact = artifacts.artifacts.find(
109+
artifact => artifact.name === "Beat analyzer report"
110+
);
111+
112+
if (!targetArtifact) {
113+
console.log(`Artifact with name "${targetArtifactName}" not found.`);
114+
return false;
115+
}
116+
117+
console.log(`Found target artifact: ${targetArtifact.name}, ID: ${targetArtifact.id}`);
118+
console.log(`Download URL: ${targetArtifact.archive_download_url}`);
119+
120+
// Optionally, download the artifact
121+
const artifact_download_url = latest_artifact.archive_download_url;
122+
const artifact_response = await fetch(artifact_download_url, {
123+
headers: {
124+
'Authorization': `token ${process.env.GITHUB_TOKEN}`,
125+
'Accept': 'application/vnd.github.v3+json',
126+
},
127+
});
128+
const artifact_data = await artifact_response.buffer();
129+
130+
const fs = require('fs');
131+
fs.writeFileSync('report.zip', artifact_data);
132+
console.log('Artifact downloaded as report.zip');
133+
return true;
134+
- name: Extra report
135+
if: steps.resolve.outputs.result == 'true'
136+
id: report
137+
run: |
138+
unzip report.zip
139+
ls -l
140+
echo "previous_snapshot=$(base64 -w0 report/snapshot.json)" >> $GITHUB_OUTPUT
141+
142+
analyzer_report:
143+
needs: [fetch_beat_analyzer_report]
144+
if: needs.fetch_beat_analyzer_report.outcome == 'success'
145+
uses: ./.github/workflows/beat_analyzer.yml
146+
with:
147+
branch: ${{ github.head_ref || github.ref_name }}

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ jobs:
5050
with:
5151
branch: ${{ github.head_ref || github.ref_name }}
5252

53+
analyzer_report:
54+
uses: ./.github/workflows/beat_analyzer.yml
55+
with:
56+
branch: ${{ github.head_ref || github.ref_name }}
57+
publish_report: true
58+
5359
sync:
5460
if: ${{ github.ref != 'refs/heads/main' && github.repository == 'mixxxdj/mixxx' }}
5561
uses: ./.github/workflows/sync_branches.yml

tools/analyzer_benchmark.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,6 @@ def serialize(obj):
519519
json.dump(
520520
dict(results=results, stats=stats),
521521
f,
522-
sort_keys=True,
523-
indent=4,
524522
default=serialize,
525523
)
526524

0 commit comments

Comments
 (0)