Skip to content

Commit 0abc83a

Browse files
committed
👷 fix: test only changed packages and tolerate moderation
1 parent 500858a commit 0abc83a

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

‎.github/workflows/publish-packages.yml‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,13 @@ jobs:
6868

6969
- name: Push to the community repository
7070
if: steps.published.outputs.published == 'false'
71-
run: choco push "${{ matrix.package }}.${{ steps.nuspec.outputs.version }}.nupkg" --source="https://push.chocolatey.org/" --api-key="${{ secrets.CHOCO_API_KEY }}"
71+
run: |
72+
$output = choco push "${{ matrix.package }}.${{ steps.nuspec.outputs.version }}.nupkg" --source="https://push.chocolatey.org/" --api-key="${{ secrets.CHOCO_API_KEY }}" 2>&1 | Out-String
73+
$code = $LASTEXITCODE
74+
Write-Host $output
75+
if ($code -eq 0) { exit 0 }
76+
if ($output -match 'already exists') {
77+
Write-Host "${{ matrix.package }} ${{ steps.nuspec.outputs.version }} is awaiting moderation; nothing to do."
78+
exit 0
79+
}
80+
exit $code

‎.github/workflows/test-packages.yml‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,54 @@ defaults:
2020
shell: pwsh
2121

2222
jobs:
23+
select:
24+
name: Select packages
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 5
27+
outputs:
28+
packages: ${{ steps.select.outputs.packages }}
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Select packages to test
36+
id: select
37+
shell: bash
38+
run: |
39+
all='["git-sumi","shuku","zola"]'
40+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
41+
if [ "${{ inputs.package }}" = "all" ]; then
42+
packages="$all"
43+
else
44+
packages='["${{ inputs.package }}"]'
45+
fi
46+
else
47+
changed=$(git diff --name-only \
48+
"${{ github.event.pull_request.base.sha }}" \
49+
"${{ github.event.pull_request.head.sha }}")
50+
if echo "$changed" | grep -qE '^(\.github/workflows/|scripts/)'; then
51+
packages="$all"
52+
else
53+
packages=$(echo "$changed" \
54+
| awk -F/ '/^(git-sumi|shuku|zola)\//{print $1}' \
55+
| sort -u | jq -R . | jq -sc .)
56+
fi
57+
fi
58+
echo "Testing: $packages"
59+
echo "packages=$packages" >> "$GITHUB_OUTPUT"
60+
2361
test:
2462
name: Test ${{ matrix.package }}
63+
needs: select
64+
if: needs.select.outputs.packages != '[]'
2565
runs-on: windows-latest
2666
timeout-minutes: 15
2767
strategy:
2868
fail-fast: false
2969
matrix:
30-
package: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.package != 'all') && fromJson(format('["{0}"]', github.event.inputs.package)) || fromJson('["git-sumi", "shuku", "zola"]') }}
70+
package: ${{ fromJson(needs.select.outputs.packages) }}
3171
steps:
3272
- name: Checkout repository
3373
uses: actions/checkout@v4

0 commit comments

Comments
 (0)