-
Notifications
You must be signed in to change notification settings - Fork 0
Changed: Refactor workflow structure and extract artifact naming logic #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Sewer56
commented
Dec 2, 2025
- Extract artifact name generation to scripts/get-artifact-name.sh with named parameters
- Refactor action.yml to use new artifact naming script instead of inline logic
- Consolidate test-friendly-names.yml and test-unfriendly-names.yml into test-artifact-names.yml
- Add comprehensive artifact name testing with 18 matrix combinations (9 targets × 2 friendly-name settings)
- Rename test-build-workflow.yml to test-build-options.yml and remove redundant test jobs
- Extract artifact name generation to scripts/get-artifact-name.sh with named parameters - Refactor action.yml to use new artifact naming script instead of inline logic - Consolidate test-friendly-names.yml and test-unfriendly-names.yml into test-artifact-names.yml - Add comprehensive artifact name testing with 18 matrix combinations (9 targets × 2 friendly-name settings) - Rename test-build-workflow.yml to test-build-options.yml and remove redundant test jobs
| strategy: | ||
| matrix: | ||
| include: | ||
| # Linux targets - friendly names | ||
| - use-friendly-target-names: "true" | ||
| target: x86_64-unknown-linux-gnu | ||
| expected-binary-name: "test-crate-linux-x64" | ||
| expected-binary-symbols-name: "test-crate-linux-x64.symbols" | ||
| expected-library-name: "C-Library-test-crate-linux-x64" | ||
| expected-library-symbols-name: "C-Library-test-crate-linux-x64.symbols" | ||
| - use-friendly-target-names: "true" | ||
| target: i686-unknown-linux-gnu | ||
| expected-binary-name: "test-crate-linux-x86" | ||
| expected-binary-symbols-name: "test-crate-linux-x86.symbols" | ||
| expected-library-name: "C-Library-test-crate-linux-x86" | ||
| expected-library-symbols-name: "C-Library-test-crate-linux-x86.symbols" | ||
| - use-friendly-target-names: "true" | ||
| target: aarch64-unknown-linux-gnu | ||
| expected-binary-name: "test-crate-linux-arm64" | ||
| expected-binary-symbols-name: "test-crate-linux-arm64.symbols" | ||
| expected-library-name: "C-Library-test-crate-linux-arm64" | ||
| expected-library-symbols-name: "C-Library-test-crate-linux-arm64.symbols" | ||
| - use-friendly-target-names: "true" | ||
| target: armv7-unknown-linux-gnueabihf | ||
| expected-binary-name: "test-crate-linux-armv7-hf" | ||
| expected-binary-symbols-name: "test-crate-linux-armv7-hf.symbols" | ||
| expected-library-name: "C-Library-test-crate-linux-armv7-hf" | ||
| expected-library-symbols-name: "C-Library-test-crate-linux-armv7-hf.symbols" | ||
| # Linux targets - raw triples | ||
| - use-friendly-target-names: "false" | ||
| target: x86_64-unknown-linux-gnu | ||
| expected-binary-name: "test-crate-x86_64-unknown-linux-gnu" | ||
| expected-binary-symbols-name: "test-crate-x86_64-unknown-linux-gnu.symbols" | ||
| expected-library-name: "C-Library-test-crate-x86_64-unknown-linux-gnu" | ||
| expected-library-symbols-name: "C-Library-test-crate-x86_64-unknown-linux-gnu.symbols" | ||
| - use-friendly-target-names: "false" | ||
| target: i686-unknown-linux-gnu | ||
| expected-binary-name: "test-crate-i686-unknown-linux-gnu" | ||
| expected-binary-symbols-name: "test-crate-i686-unknown-linux-gnu.symbols" | ||
| expected-library-name: "C-Library-test-crate-i686-unknown-linux-gnu" | ||
| expected-library-symbols-name: "C-Library-test-crate-i686-unknown-linux-gnu.symbols" | ||
| - use-friendly-target-names: "false" | ||
| target: aarch64-unknown-linux-gnu | ||
| expected-binary-name: "test-crate-aarch64-unknown-linux-gnu" | ||
| expected-binary-symbols-name: "test-crate-aarch64-unknown-linux-gnu.symbols" | ||
| expected-library-name: "C-Library-test-crate-aarch64-unknown-linux-gnu" | ||
| expected-library-symbols-name: "C-Library-test-crate-aarch64-unknown-linux-gnu.symbols" | ||
| - use-friendly-target-names: "false" | ||
| target: armv7-unknown-linux-gnueabihf | ||
| expected-binary-name: "test-crate-armv7-unknown-linux-gnueabihf" | ||
| expected-binary-symbols-name: "test-crate-armv7-unknown-linux-gnueabihf.symbols" | ||
| expected-library-name: "C-Library-test-crate-armv7-unknown-linux-gnueabihf" | ||
| expected-library-symbols-name: "C-Library-test-crate-armv7-unknown-linux-gnueabihf.symbols" | ||
| # Windows targets - friendly names | ||
| - use-friendly-target-names: "true" | ||
| target: x86_64-pc-windows-msvc | ||
| expected-binary-name: "test-crate-windows-x64" | ||
| expected-binary-symbols-name: "test-crate-windows-x64.symbols" | ||
| expected-library-name: "C-Library-test-crate-windows-x64" | ||
| expected-library-symbols-name: "C-Library-test-crate-windows-x64.symbols" | ||
| - use-friendly-target-names: "true" | ||
| target: i686-pc-windows-msvc | ||
| expected-binary-name: "test-crate-windows-x86" | ||
| expected-binary-symbols-name: "test-crate-windows-x86.symbols" | ||
| expected-library-name: "C-Library-test-crate-windows-x86" | ||
| expected-library-symbols-name: "C-Library-test-crate-windows-x86.symbols" | ||
| - use-friendly-target-names: "true" | ||
| target: aarch64-pc-windows-msvc | ||
| expected-binary-name: "test-crate-windows-arm64" | ||
| expected-binary-symbols-name: "test-crate-windows-arm64.symbols" | ||
| expected-library-name: "C-Library-test-crate-windows-arm64" | ||
| expected-library-symbols-name: "C-Library-test-crate-windows-arm64.symbols" | ||
| # Windows targets - raw triples | ||
| - use-friendly-target-names: "false" | ||
| target: x86_64-pc-windows-msvc | ||
| expected-binary-name: "test-crate-x86_64-pc-windows-msvc" | ||
| expected-binary-symbols-name: "test-crate-x86_64-pc-windows-msvc.symbols" | ||
| expected-library-name: "C-Library-test-crate-x86_64-pc-windows-msvc" | ||
| expected-library-symbols-name: "C-Library-test-crate-x86_64-pc-windows-msvc.symbols" | ||
| - use-friendly-target-names: "false" | ||
| target: i686-pc-windows-msvc | ||
| expected-binary-name: "test-crate-i686-pc-windows-msvc" | ||
| expected-binary-symbols-name: "test-crate-i686-pc-windows-msvc.symbols" | ||
| expected-library-name: "C-Library-test-crate-i686-pc-windows-msvc" | ||
| expected-library-symbols-name: "C-Library-test-crate-i686-pc-windows-msvc.symbols" | ||
| - use-friendly-target-names: "false" | ||
| target: aarch64-pc-windows-msvc | ||
| expected-binary-name: "test-crate-aarch64-pc-windows-msvc" | ||
| expected-binary-symbols-name: "test-crate-aarch64-pc-windows-msvc.symbols" | ||
| expected-library-name: "C-Library-test-crate-aarch64-pc-windows-msvc" | ||
| expected-library-symbols-name: "C-Library-test-crate-aarch64-pc-windows-msvc.symbols" | ||
| # macOS targets - friendly names | ||
| - use-friendly-target-names: "true" | ||
| target: x86_64-apple-darwin | ||
| expected-binary-name: "test-crate-macos-x64" | ||
| expected-binary-symbols-name: "test-crate-macos-x64.symbols" | ||
| expected-library-name: "C-Library-test-crate-macos-x64" | ||
| expected-library-symbols-name: "C-Library-test-crate-macos-x64.symbols" | ||
| - use-friendly-target-names: "true" | ||
| target: aarch64-apple-darwin | ||
| expected-binary-name: "test-crate-macos-arm64" | ||
| expected-binary-symbols-name: "test-crate-macos-arm64.symbols" | ||
| expected-library-name: "C-Library-test-crate-macos-arm64" | ||
| expected-library-symbols-name: "C-Library-test-crate-macos-arm64.symbols" | ||
| # macOS targets - raw triples | ||
| - use-friendly-target-names: "false" | ||
| target: x86_64-apple-darwin | ||
| expected-binary-name: "test-crate-x86_64-apple-darwin" | ||
| expected-binary-symbols-name: "test-crate-x86_64-apple-darwin.symbols" | ||
| expected-library-name: "C-Library-test-crate-x86_64-apple-darwin" | ||
| expected-library-symbols-name: "C-Library-test-crate-x86_64-apple-darwin.symbols" | ||
| - use-friendly-target-names: "false" | ||
| target: aarch64-apple-darwin | ||
| expected-binary-name: "test-crate-aarch64-apple-darwin" | ||
| expected-binary-symbols-name: "test-crate-aarch64-apple-darwin.symbols" | ||
| expected-library-name: "C-Library-test-crate-aarch64-apple-darwin" | ||
| expected-library-symbols-name: "C-Library-test-crate-aarch64-apple-darwin.symbols" | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Action | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Test binary artifact name | ||
| shell: bash | ||
| run: | | ||
| ARTIFACT_NAME=$(./scripts/get-artifact-name.sh \ | ||
| --crate-name test-crate \ | ||
| --target ${{ matrix.target }} \ | ||
| --use-friendly-target-names ${{ matrix.use-friendly-target-names }} \ | ||
| --artifact-type binary) | ||
| EXPECTED="${{ matrix.expected-binary-name }}" | ||
| echo "BINARY_ARTIFACT_NAME=$ARTIFACT_NAME" | ||
| if [[ "$ARTIFACT_NAME" != "$EXPECTED" ]]; then | ||
| echo "::error::Expected '$EXPECTED' but got '$ARTIFACT_NAME'" | ||
| exit 1 | ||
| fi | ||
| echo "Binary artifact name correct: $ARTIFACT_NAME" | ||
|
|
||
| - name: Test binary-symbols artifact name | ||
| shell: bash | ||
| run: | | ||
| ARTIFACT_NAME=$(./scripts/get-artifact-name.sh \ | ||
| --crate-name test-crate \ | ||
| --target ${{ matrix.target }} \ | ||
| --use-friendly-target-names ${{ matrix.use-friendly-target-names }} \ | ||
| --artifact-type binary-symbols) | ||
| EXPECTED="${{ matrix.expected-binary-symbols-name }}" | ||
| echo "BINARY_SYMBOLS_ARTIFACT_NAME=$ARTIFACT_NAME" | ||
| if [[ "$ARTIFACT_NAME" != "$EXPECTED" ]]; then | ||
| echo "::error::Expected '$EXPECTED' but got '$ARTIFACT_NAME'" | ||
| exit 1 | ||
| fi | ||
| echo "Binary symbols artifact name correct: $ARTIFACT_NAME" | ||
|
|
||
| - name: Test library artifact name | ||
| shell: bash | ||
| run: | | ||
| ARTIFACT_NAME=$(./scripts/get-artifact-name.sh \ | ||
| --crate-name test-crate \ | ||
| --target ${{ matrix.target }} \ | ||
| --use-friendly-target-names ${{ matrix.use-friendly-target-names }} \ | ||
| --artifact-type library) | ||
| EXPECTED="${{ matrix.expected-library-name }}" | ||
| echo "LIBRARY_ARTIFACT_NAME=$ARTIFACT_NAME" | ||
| if [[ "$ARTIFACT_NAME" != "$EXPECTED" ]]; then | ||
| echo "::error::Expected '$EXPECTED' but got '$ARTIFACT_NAME'" | ||
| exit 1 | ||
| fi | ||
| echo "Library artifact name correct: $ARTIFACT_NAME" | ||
|
|
||
| - name: Test library-symbols artifact name | ||
| shell: bash | ||
| run: | | ||
| ARTIFACT_NAME=$(./scripts/get-artifact-name.sh \ | ||
| --crate-name test-crate \ | ||
| --target ${{ matrix.target }} \ | ||
| --use-friendly-target-names ${{ matrix.use-friendly-target-names }} \ | ||
| --artifact-type library-symbols) | ||
| EXPECTED="${{ matrix.expected-library-symbols-name }}" | ||
| echo "LIBRARY_SYMBOLS_ARTIFACT_NAME=$ARTIFACT_NAME" | ||
| if [[ "$ARTIFACT_NAME" != "$EXPECTED" ]]; then | ||
| echo "::error::Expected '$EXPECTED' but got '$ARTIFACT_NAME'" | ||
| exit 1 | ||
| fi | ||
| echo "Library symbols artifact name correct: $ARTIFACT_NAME" | ||
|
|
||
| test-artifact-names-with-features: |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 4 hours ago
To fix the problem, add a permissions: key to the workflow root, specifying the minimal permissions required. For workflows that only check out code and do not interact with issues, pull requests, or perform deploys or artifact uploads, contents: read is sufficient. This block should be placed after the name: or on: sections, and before jobs:. In this workflow's structure, adding it after the on: block is standard. No method, import, or definition is required, just YAML structure changes in .github/workflows/test-artifact-names.yml.
-
Copy modified lines R15-R17
| @@ -12,6 +12,9 @@ | ||
| - "scripts/get-friendly-target-name.sh" | ||
| - ".github/workflows/test-artifact-names.yml" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test-artifact-names: | ||
| strategy: |
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Action | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Test binary with features | ||
| shell: bash | ||
| run: | | ||
| ARTIFACT_NAME=$(./scripts/get-artifact-name.sh \ | ||
| --crate-name test-crate \ | ||
| --target x86_64-unknown-linux-gnu \ | ||
| --features "feature1,feature2" \ | ||
| --use-friendly-target-names true \ | ||
| --artifact-type binary) | ||
| EXPECTED="test-crate-linux-x64-feature1,feature2" | ||
| echo "ARTIFACT_NAME_WITH_FEATURES=$ARTIFACT_NAME" | ||
| if [[ "$ARTIFACT_NAME" != "$EXPECTED" ]]; then | ||
| echo "::error::Expected '$EXPECTED' but got '$ARTIFACT_NAME'" | ||
| exit 1 | ||
| fi | ||
| echo "Feature suffix correctly appended: $ARTIFACT_NAME" | ||
|
|
||
| - name: Test binary-symbols with features | ||
| shell: bash | ||
| run: | | ||
| ARTIFACT_NAME=$(./scripts/get-artifact-name.sh \ | ||
| --crate-name test-crate \ | ||
| --target x86_64-unknown-linux-gnu \ | ||
| --features "feature1,feature2" \ | ||
| --use-friendly-target-names true \ | ||
| --artifact-type binary-symbols) | ||
| EXPECTED="test-crate-linux-x64-feature1,feature2.symbols" | ||
| echo "ARTIFACT_NAME_WITH_FEATURES=$ARTIFACT_NAME" | ||
| if [[ "$ARTIFACT_NAME" != "$EXPECTED" ]]; then | ||
| echo "::error::Expected '$EXPECTED' but got '$ARTIFACT_NAME'" | ||
| exit 1 | ||
| fi | ||
| echo "Feature suffix correctly appended: $ARTIFACT_NAME" | ||
|
|
||
| - name: Test library with features | ||
| shell: bash | ||
| run: | | ||
| ARTIFACT_NAME=$(./scripts/get-artifact-name.sh \ | ||
| --crate-name test-crate \ | ||
| --target x86_64-unknown-linux-gnu \ | ||
| --features "feature1,feature2" \ | ||
| --use-friendly-target-names true \ | ||
| --artifact-type library) | ||
| EXPECTED="C-Library-test-crate-linux-x64-feature1,feature2" | ||
| echo "ARTIFACT_NAME_WITH_FEATURES=$ARTIFACT_NAME" | ||
| if [[ "$ARTIFACT_NAME" != "$EXPECTED" ]]; then | ||
| echo "::error::Expected '$EXPECTED' but got '$ARTIFACT_NAME'" | ||
| exit 1 | ||
| fi | ||
| echo "Feature suffix correctly appended: $ARTIFACT_NAME" | ||
|
|
||
| - name: Test library-symbols with features | ||
| shell: bash | ||
| run: | | ||
| ARTIFACT_NAME=$(./scripts/get-artifact-name.sh \ | ||
| --crate-name test-crate \ | ||
| --target x86_64-unknown-linux-gnu \ | ||
| --features "feature1,feature2" \ | ||
| --use-friendly-target-names true \ | ||
| --artifact-type library-symbols) | ||
| EXPECTED="C-Library-test-crate-linux-x64-feature1,feature2.symbols" | ||
| echo "ARTIFACT_NAME_WITH_FEATURES=$ARTIFACT_NAME" | ||
| if [[ "$ARTIFACT_NAME" != "$EXPECTED" ]]; then | ||
| echo "::error::Expected '$EXPECTED' but got '$ARTIFACT_NAME'" | ||
| exit 1 | ||
| fi | ||
| echo "Feature suffix correctly appended: $ARTIFACT_NAME" |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 4 hours ago
The best way to fix this problem is to add an explicit permissions block to the workflow file .github/workflows/test-artifact-names.yml, either at the root level (to affect all jobs) or to the jobs that do not have their own specified permissions. Since none of the jobs appear to need write access—for example, they simply run shell scripts to verify artifact names—it is sufficient to set contents: read (the minimal required permission for most workflows that only need to read code). Place the block immediately before the jobs: key for best readability and maintainability. No other code or imports need to be changed; this is entirely a YAML config edit.
-
Copy modified lines R15-R16
| @@ -12,6 +12,8 @@ | ||
| - "scripts/get-friendly-target-name.sh" | ||
| - ".github/workflows/test-artifact-names.yml" | ||
|
|
||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| test-artifact-names: | ||
| strategy: |