Repository navigation
93 lines (87 loc) · 3.76 KB
/
Copy pathmemory.yml
File metadata and controls
93 lines (87 loc) · 3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Copyright 2026 Han Li and contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# The memory of the implementation in a pull request. The workflows of mygo
# and android measure the application and upload the results as the artifacts
# memory-mygo, memory-lightweight and memory-android. When the runs have
# ended for the latest commit of a pull request, this workflow writes one
# comment on it: the memory with the difference from the latest numbers of
# main. Later runs replace that comment instead of adding another one
# (vfxtool memory-report; docs/en/dev/memory.md#memory-in-pull-requests).
#
# It runs after the workflow of the pull request, in the context of the default
# branch, so that it can write to pull requests of forks, which a pull_request
# workflow cannot. For the same reason it never runs code of the pull request:
# it checks out main, and the artifacts it downloads are data, of which the
# script only reads numbers.
#
# Run it by hand to write the report of a pull request again:
# gh workflow run memory.yml -f pull_request=<number>
name: Memory
on:
workflow_run:
# The workflows that measure the implementation, by name. Keep this in sync
# with MEMORY_IMPLEMENTATIONS below, which has its file name, and with the
# android workflow, whose run carries the APK section of the report.
workflows: [mygo, android]
types: [completed]
workflow_dispatch:
inputs:
pull_request:
description: The number of the pull request to write the report of now
required: true
type: number
permissions:
actions: read
contents: read
pull-requests: write
concurrency:
# The run of a commit ends and then starts a report. Reports run one at a
# time, so that two of them cannot both write the comment.
group: memory-${{ github.event.workflow_run.head_sha || format('pull-request-{0}', inputs.pull_request) }}
cancel-in-progress: false
env:
# The file name of the workflow of the implementation (without .yml), which
# is also the name of its directory and of its artifact.
MEMORY_IMPLEMENTATIONS: mygo
jobs:
report:
name: Write the report
# Forks do not run CI.
if: >-
github.repository == 'version-fox/vfox-plus' &&
(github.event_name == 'workflow_dispatch' || github.event.workflow_run.event == 'pull_request')
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Read the pinned versions
run: grep -hE '^[A-Z0-9_]+=' mygo/versions.env >> "$GITHUB_ENV"
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ env.GO_VERSION }}
- name: Write the report
env:
GH_TOKEN: ${{ github.token }}
RUN_ID: ${{ github.event.workflow_run.id }}
PULL_REQUEST: ${{ inputs.pull_request }}
run: |
if [[ -n "$RUN_ID" ]]; then
go -C shared/tooling build -o "$RUNNER_TEMP/vfxtool" ./cmd/vfxtool
"$RUNNER_TEMP/vfxtool" memory-report --run "$RUN_ID"
else
go -C shared/tooling build -o "$RUNNER_TEMP/vfxtool" ./cmd/vfxtool
"$RUNNER_TEMP/vfxtool" memory-report --pull-request "$PULL_REQUEST"
fi