Skip to content

Commit 6a23d93

Browse files
workflows
Potential fix for code scanning alert no. 19: Workflow does not contain permissions workflows distinct_id removed. Now that gh cli can get the id of a workflow it starts we do not need to use this workaround + action. Update ci-alpine-release.yml Co-Authored-By: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent e29af77 commit 6a23d93

File tree

7 files changed

+119
-102
lines changed

7 files changed

+119
-102
lines changed

.github/copilot-instructions.md

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Purpose: Make AI contributions precise, minimal, and correct. Follow these rules
55
## Bash scripting (applies to all repos)
66

77
Do
8+
89
- Use `#!/bin/bash` as the shebang for Bash scripts.
910
- Use the `.bash` extension for Bash; use `.sh` only for POSIX-only scripts.
1011
- Prefer `$BASH_SOURCE` over `$0` for script path detection.
@@ -17,31 +18,40 @@ Do
1718
- For Bash references, consult: https://mywiki.wooledge.org and https://mywiki.wooledge.org/BashFAQ and include a source link when possible. Do not invent links.
1819

1920
Avoid
20-
- Global “set -euo pipefail”; prefer targeted checks and explicit error handling.
21+
22+
- `set -euo pipefail`; prefer targeted checks and explicit error handling.
2123
- Uppercase variable names for general scripting (reserve UPPERCASE for Docker/env settings).
2224
- Clever one-liners that harm clarity.
2325
- Generalized or speculative changes not asked for in the prompt.
2426
- Over-engineering; keep it stable, concise, and C-like in mindset.
2527

2628
Scope and behavior
27-
- Only implement what the prompt requests.
29+
30+
- Only implement what the prompt requests. All changes should be in the context of the prompt.
2831
- Keep solutions minimal and modular; do not add placeholders or future-proofing unless required.
2932
- When giving Bash/shell answers, add a relevant wooledge link if helpful; never fabricate links.
3033

3134
## GitHub Workflows (all repos)
3235

3336
- In reusable workflows, any job that uses outputs from another job must declare that job in `needs` to avoid null outputs.
3437
- Do not use outdated Actions. Check for current recommended versions before editing.
35-
- The `gh` CLI cannot fetch the ID of a workflow run it just started via `gh run workflow`. List runs afterward and extract the ID.
38+
- gh cli can get gets the id of a workflow it starts, here is an example usage
39+
40+
```bash
41+
run_url="$(~/bin/gh workflow run ci-main-reusable-caller.yml --repo user/repo -f skip_rerun=false -f retries=3)"
42+
~/bin/gh run watch "${run_url##*/}" --repo user/repo --exit-status --compact --interval 30
43+
```
3644

3745
## If repo name matches `*-musl-cross-make`
3846

3947
Toolchain specifics
48+
4049
- Use both `-static` and `--static` to produce static toolchain binaries. Using only `-static` can miss POSIX threads.
4150
- When using `../config.mak`, always load options from both `../gcc-configure-options.md` and `../gcc-configure-options-recursive.md`.
4251
- The binutils gold linker is deprecated. Use `ld=default` and `--disable-gold`.
4352

4453
Fully static toolchains with musl
54+
4555
- Do not use LTO: avoid `-flto` and `-fuse-linker-plugin`.
4656
- Do not add any LTO-related settings.
4757
- Only set linker options such as `LDFLAGS` at link time, not during library builds.
@@ -52,53 +62,63 @@ Fully static toolchains with musl
5262
## Debugging with QEMU
5363

5464
- Start the target under QEMU with gdbstub, then attach with gdb:
55-
- `qemu -g <port> <binary>` (e.g., `qemu -g 1234 ./qbt-nox-static`)
56-
- In another terminal: `gdb ./qbt-nox-static` and `target remote :1234`
65+
- `qemu -g <port> <binary>` (e.g., `qemu -g 1234 ./qbt-nox-static`)
66+
- In another terminal: `gdb ./qbt-nox-static` and `target remote :1234`
5767

5868
## If repo name matches `*qbittorrent-nox-static`
5969

6070
`qi.bash` script goals
71+
6172
- Simple installer that verifies installation and binaries.
6273
- Shebang must be `#!/bin/bash`.
6374

6475
OS detection
76+
6577
- `source /etc/os-release`.
6678
- Supported: `ID=alpine`, `ID=debian`, or `ID_LIKE` contains `debian`. Otherwise exit with a clear reason.
6779

6880
Transfer tools
81+
6982
- Prefer `curl` if present; use `wget` if present and `curl` is not; exit if neither is available.
7083
- Detect presence of `gh` CLI and use it when available, but it is not required.
7184

7285
Architecture detection
86+
7387
- Alpine: `apk --print-arch`.
7488
- Debian-like: `dpkg --print-architecture`.
7589
- Architectures are the same across distros except `armhf`: Debian uses `armv7`, Alpine uses `armv6`.
7690
- If architecture is not valid/supported, exit with a reason.
7791

7892
Download function
93+
7994
- Build the download URL from the detected architecture.
8095
- Create and store the download’s SHA-256 sum.
8196

8297
Attestation (optional)
98+
8399
- When `gh` CLI is available and usable, verify downloaded binaries:
84-
- `gh attestation verify <INSTALL_PATH> --repo <REPO> 2> /dev/null`
100+
- `gh attestation verify <INSTALL_PATH> --repo <REPO> 2> /dev/null`
85101

86102
Error handling
103+
87104
- Provide a helper that checks command exit codes and exits with a concise, helpful message on failure.
88105

89106
Output formatting
107+
90108
- Provide a print helper that supports:
91-
- `[INFO]` (blue), `[WARNING]` (yellow), `[ERROR]` (red), `[SUCCESS]` (green), `[FAILURE]` (magenta)
109+
- `[INFO]` (blue), `[WARNING]` (yellow), `[ERROR]` (red), `[SUCCESS]` (green), `[FAILURE]` (magenta)
92110
- Use `printf '%s'` and `printf '%b'`; do not use `echo`.
93111
- Keep messages succinct. Be verbose only on errors to aid troubleshooting.
94112

95113
---
96114

97115
Meta for AI contributors
116+
98117
- Be conservative: do only what the prompt requests. No broad refactors.
99118
- Prefer small, well-named functions and staged changes.
100119
- Preserve existing public behavior and style unless the prompt requires changes.
101120
- If something cannot be done with available context/tools, state why and propose the smallest viable alternative.
121+
102122
# Bash Scripting - All repos
103123

104124
- use $BASH_SOURCE instead of $0
@@ -128,8 +148,10 @@ Meta for AI contributors
128148
- Do not use outdated GitHub Actions in workflow code. Always check the version recommended is the current version
129149
- The `gh` CLI cannot get the ID of a workflow it started with `gh run workflow`; you must list runs after and extract the ID.
130150

131-
# If repo = *-musl-cross-make
151+
# If repo = \*-musl-cross-make
152+
132153
GCC / Binutils
154+
133155
- Use both `-static` and `--static` to create static toolchain binaries. Using `-static` alone can cause errors (e.g., missing POSIX threads).
134156
- When working with `../config.mak`, always load options from both `../gcc-configure-options.md` and `../gcc-configure-options-recursive.md`.
135157
- The binutils gold linker is deprecated. Use `ld=default` and `--disable-gold`.
@@ -146,42 +168,50 @@ GCC / Binutils
146168
- To debug with QEMU:
147169
Run `qemu -g <port> <binary>` (e.g., `qemu -g 1234 ./qbt-nox-static`), then connect with `gdb ./qbt-nox-static` in another terminal.
148170

149-
# If repo = * qbittorrent-nox-static
171+
# If repo = \* qbittorrent-nox-static
150172

151173
## qi.bash script
152174

153175
General features
176+
154177
- Always use `#!/bin/bash` as the shebang.
155178
- this script is focused on being a simple installer that verifies installation and binaries.
156179

157180
basic check for supported os
181+
158182
- use source /etc/os-release
159183
- if ID = alpine of debian or if the or if ID_LIKE=debian is debian like we can proceed.
160184
- if not supported os exit with reason.
161185

162186
basic check for wget or curl, default to curl if present.
187+
163188
- if no tools exit with reason.
164189
- wget or curl must have, curl default if present but use wget if there.
165190
- check if gh cli is available to use but no required.
166191

167192
basic check of which arch using
193+
168194
- alpine use apk --print-arch
169195
- debian like use dpkg --print-architecture
170196
- all arches are the same except armhf. on debian this is armv7 and alpine armv6
171197
- if not valid arch exit with reason.
172198

173199
create download function based on arch checks.
200+
174201
- configure download url based on arch.
175202
- creates sha256 of download.
176203

177204
gh cli function
205+
178206
- if gh cli exists and is usable use it to very the binaries downloaded
179207
- if gh attestation verify <INSTALL_PATH> --repo <REPO> 2> /dev/null; then ...
180208

181209
error handling
210+
182211
- there should be a error handling function to test commands exit the script with helpful explanations when a command or function fails.
183212

184213
ouputs
214+
185215
- there should be a function to handle printing outputs.
186216
- It should handle [INFO] (blue) [WARNING] (yellow) [ERROR] (red) [SUCCESS] (Green) [FAILURE] (magenta)
187217
- Use `printf '%s'` for printing strings and `printf '%b'` for escape sequences. **Avoid using `echo`.**

.github/workflows/ci-alpine-build.yml

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: ci - alpine build
33
on:
44
workflow_call:
55
inputs:
6-
distinct_id:
7-
description: "Distinct id"
8-
required: false
9-
type: string
106
workflow-files:
117
description: "Alpine: workflow-files files"
128
required: true
@@ -57,21 +53,22 @@ jobs:
5753
workspace: ${{ github.workspace }}
5854

5955
steps:
60-
- name: Checkout ${{ inputs.distinct_id }}
56+
- name: Checkout
6157
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6258
with:
6359
persist-credentials: false
6460

6561
- name: Download ${{ env.script_name }}
62+
env:
63+
GH_TOKEN: "${{ github.token }}"
6664
run: |
67-
# Make sure the branch is set to master for qbittorrent-nox-static and main qbittorrent-nox-static-test
6865
if [[ ! -f "${script_name}" ]]; then
69-
echo "Downloading ${script_name} from userdocs/qbittorrent-nox-static"
70-
curl -LO "https://raw.githubusercontent.com/userdocs/qbittorrent-nox-static/refs/heads/master/${script_name}"
66+
gh api "repos/${{ github.repository }}/contents/${script_name}" \
67+
--header "Accept: application/vnd.github.raw+json" > "${script_name}"
7168
chmod +x "${script_name}"
7269
fi
7370
74-
- name: Host - Create Docker template env file ${{ inputs.distinct_id }}
71+
- name: Host - Create Docker template env file
7572
run: |
7673
printf '%s\n' "qbt_revision_url=${{ github.repository }}" > env.custom
7774
printf '%s\n' "qbt_zlib_type=zlib" >> env.custom
@@ -99,7 +96,7 @@ jobs:
9996
printf '%s\n' "qbt_host_deps=${set_qbt_host_deps}" >> env.custom
10097
printf '%s\n\n' "qbt_host_deps_repo=${set_qbt_host_deps_repo}" >> env.custom
10198
102-
- name: Host - Debian based specific env ${{ inputs.distinct_id }}
99+
- name: Host - Debian based specific env
103100
if: matrix.os_id != 'alpine'
104101
run: |
105102
printf '%s\n' "LANG=C.UTF-8" >> env.custom
@@ -118,68 +115,68 @@ jobs:
118115
os_version_id: ${{ matrix.os_version_id }}
119116
additional_apps: "curl git"
120117

121-
- name: Host - patches ${{ inputs.distinct_id }}
118+
- name: Host - patches
122119
if: hashFiles('patches/**') != ''
123120
run: mkdir -p "${qbt_build_dir}/patches" && cp -rf patches/* "${qbt_build_dir}/patches/"
124121

125-
- name: Docker - bootstrap_deps ${{ inputs.distinct_id }}
122+
- name: Docker - bootstrap_deps
126123
if: inputs.script_name == 'qbt-nox-static.bash'
127124
run: docker exec "${container_name}" bash "${script_name}" bootstrap_deps
128125

129-
- name: Docker - Bootstrap build ${{ inputs.distinct_id }}
126+
- name: Docker - Bootstrap build
130127
run: docker exec "${container_name}" bash "${script_name}" -bs-a
131128

132-
- name: Docker - glibc ${{ inputs.distinct_id }}
129+
- name: Docker - glibc
133130
if: matrix.os_id != 'alpine'
134131
run: docker exec "${container_name}" bash "${script_name}" glibc
135132

136-
- name: Docker - zlib ${{ inputs.distinct_id }}
133+
- name: Docker - zlib
137134
run: docker exec "${container_name}" bash "${script_name}" zlib
138135

139-
- name: Docker - iconv ${{ inputs.distinct_id }}
136+
- name: Docker - iconv
140137
if: matrix.qbt_libtorrent_version == '1.2'
141138
run: docker exec "${container_name}" bash "${script_name}" iconv
142139

143-
- name: Docker - icu ${{ inputs.distinct_id }}
140+
- name: Docker - icu
144141
if: env.set_skip_icu == 'no'
145142
run: docker exec "${container_name}" bash "${script_name}" icu
146143

147-
- name: Docker - openssl ${{ inputs.distinct_id }}
144+
- name: Docker - openssl
148145
run: docker exec "${container_name}" bash "${script_name}" openssl
149146

150-
- name: Docker - boost ${{ inputs.distinct_id }}
147+
- name: Docker - boost
151148
run: docker exec "${container_name}" bash "${script_name}" boost
152149

153-
- name: Docker - libtorrent ${{ inputs.distinct_id }}
150+
- name: Docker - libtorrent
154151
run: docker exec "${container_name}" bash "${script_name}" libtorrent
155152

156-
# - name: Docker - double_conversion ${{ inputs.distinct_id }}
153+
# - name: Docker - double_conversion
157154
# if: matrix.qbt_build_tool == ''
158155
# run: docker exec "${container_name}" bash "${script_name}" double_conversion
159156

160-
- name: Docker - qtbase ${{ inputs.distinct_id }}
157+
- name: Docker - qtbase
161158
run: docker exec "${container_name}" bash "${script_name}" qtbase
162159

163-
- name: Docker - qttools ${{ inputs.distinct_id }}
160+
- name: Docker - qttools
164161
run: docker exec "${container_name}" bash "${script_name}" qttools
165162

166-
- name: Docker - qbittorrent ${{ inputs.distinct_id }}
163+
- name: Docker - qbittorrent
167164
run: docker exec "${container_name}" bash "${script_name}" qbittorrent
168165

169-
- name: Docker - Set release asset name ${{ inputs.distinct_id }}
166+
- name: Docker - Set release asset name
170167
run: docker exec -w ${wd}/${qbt_build_dir}/completed "${container_name}" mv -f qbittorrent-nox "${{ matrix.qbt_cross_name }}-${{ matrix.qbt_qt_version_name }}qbittorrent-nox"
171168

172-
- name: Generate artifact attestation ${{ inputs.distinct_id }}
169+
- name: Generate artifact attestation
173170
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
174171
with:
175172
subject-path: "${{ env.qbt_build_dir }}/completed/${{ matrix.qbt_cross_name }}-${{ matrix.qbt_qt_version_name }}qbittorrent-nox"
176173

177-
- name: Docker - Release Info ${{ inputs.distinct_id }}
174+
- name: Docker - Release Info
178175
working-directory: "${{ env.workspace }}/${{ env.qbt_build_dir }}/release_info"
179176
run: |
180177
mv *.md *.json "${workspace}/${qbt_build_dir}/completed"
181178
182-
- name: Host - Upload libtorrent-v${{ matrix.qbt_libtorrent_version }}-qbittorrent-nox and release info artifact ${{ inputs.distinct_id }}
179+
- name: Host - Upload libtorrent-v${{ matrix.qbt_libtorrent_version }}-qbittorrent-nox and release info artifact
183180
if: success()
184181
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
185182
with:
@@ -188,7 +185,7 @@ jobs:
188185
${{ env.qbt_build_dir }}/completed/*
189186
!${{ env.qbt_build_dir }}/completed/*.png
190187
191-
- name: Host - Upload cmake graphs artifact ${{ inputs.distinct_id }}
188+
- name: Host - Upload cmake graphs artifact
192189
if: success() && matrix.qbt_build_tool == ''
193190
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
194191
with:

0 commit comments

Comments
 (0)