Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

CI: run the macOS packages on pull requests only when macOS is involved

KnifeLemon7c35cb308b3b
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 3682af7c..2ebc886b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,18 +16,24 @@ concurrency:
cancel-in-progress: true
jobs:
- # Decides whether the change touches anything the build depends on. The workflow always runs, so the required
- # build check always reports: a job skipped by its condition counts as passed for the branch rules. When the file
- # list can't be read, everything runs.
+ # Decides what the change needs. The workflow always runs, so the required build check always reports: a job
+ # skipped by its condition counts as passed for the branch rules.
+ # - code: anything besides documentation and repository metadata. When the file list can't be read, everything runs.
+ # - macos: the macOS packages and tests. macOS runners are few and queue, so a pull request runs them only when it
+ # touches macOS files, code that branches on macOS, the projects, packages or build scripts, or carries the
+ # `macos` label (add it, then re-run the workflow). Pushes to main always run them.
changes:
runs-on: ubuntu-24.04
- timeout-minutes: 5
+ timeout-minutes: 10
permissions:
contents: read
pull-requests: read
outputs:
code: ${{ steps.files.outputs.code }}
+ macos: ${{ steps.files.outputs.macos }}
steps:
+ - uses: actions/checkout@v7
+
- id: files
env:
GH_TOKEN: ${{ github.token }}
@@ -36,27 +42,56 @@ jobs:
BEFORE: ${{ github.event.before }}
AFTER: ${{ github.sha }}
run: |
+ everything() { echo "code=true" >> "$GITHUB_OUTPUT"; echo "macos=true" >> "$GITHUB_OUTPUT"; echo "$1"; exit 0; }
+
if [ -n "$PR" ]; then
- files=$(gh api --paginate "repos/$REPO/pulls/$PR/files" --jq '.[].filename') || files='(unreadable)'
+ files=$(gh api --paginate "repos/$REPO/pulls/$PR/files" --jq '.[].filename') || everything "File list unreadable"
elif [ -n "$BEFORE" ] && [ "$BEFORE" != 0000000000000000000000000000000000000000 ]; then
# The compare API lists at most 300 files.
- files=$(gh api "repos/$REPO/compare/$BEFORE...$AFTER" --jq 'if (.files | length) >= 300 then "(too many)" else .files[].filename end') || files='(unreadable)'
+ files=$(gh api "repos/$REPO/compare/$BEFORE...$AFTER" \
+ --jq 'if (.files | length) >= 300 then "(too many)" else .files[].filename end') || everything "File list unreadable"
else
- files='(unknown)'
+ everything "No earlier commit to compare with"
fi
+ if [ "$files" = "(too many)" ]; then everything "Too many files to list"; fi
+
code=false
+ macos=false
+ if [ -z "$PR" ]; then
+ macos=true
+ else
+ labels=$(gh api "repos/$REPO/issues/$PR/labels" --jq '.[].name') || labels=macos
+ if grep -qx macos <<< "$labels"; then macos=true; echo "Labelled macos"; fi
+ fi
+
while IFS= read -r f; do
+ [ -z "$f" ] && continue
case "$f" in
- *.md|docs/*|LICENSE|.mailmap|.github/CODEOWNERS|.github/ISSUE_TEMPLATE/*|.github/labeler.yml|.github/FUNDING.yml) ;;
- *) code=true; echo "Needs the build: $f"; break ;;
+ *.md|docs/*|LICENSE|.mailmap|.github/CODEOWNERS|.github/ISSUE_TEMPLATE/*|.github/labeler.yml|.github/FUNDING.yml)
+ continue ;;
esac
+ if [ "$code" = false ]; then echo "Needs the build: $f"; fi
+ code=true
+ if [ "$macos" = true ]; then continue; fi
+ case "$f" in
+ .github/workflows/*|build/*|installer/macos/*|*MacOS*|*.csproj|*.props|*.targets|*.slnx|global.json|src/Filee.Engines/Infrastructure/engines.json)
+ macos=true ;;
+ *.cs|*.axaml)
+ # Shared code with a macOS branch. A deleted file has no content and only counts by its name.
+ if [ -f "$f" ] && grep -qE 'IsMacOS|OSPlatform\.OSX|"osx' "$f"; then macos=true; fi ;;
+ esac
+ if [ "$macos" = true ]; then echo "Needs macOS: $f"; fi
done <<< "$files"
+
echo "code=$code" >> "$GITHUB_OUTPUT"
+ echo "macos=$macos" >> "$GITHUB_OUTPUT"
portable:
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.code != 'false' }}
uses: ./.github/workflows/portable.yml
+ with:
+ macos: ${{ needs.changes.outputs.macos != 'false' }}
build:
needs: changes
diff --git a/.github/workflows/portable.yml b/.github/workflows/portable.yml
index 893e9790..4a6e8d52 100644
--- a/.github/workflows/portable.yml
+++ b/.github/workflows/portable.yml
@@ -13,12 +13,21 @@ on:
type: string
default: ''
required: false
+ # False leaves out the macOS packages (CI pull requests that don't touch macOS, see ci.yml).
+ macos:
+ type: boolean
+ default: true
+ required: false
workflow_dispatch:
inputs:
version:
description: 'Package version (empty uses Directory.Build.props)'
type: string
required: false
+ macos:
+ description: 'Build and test the macOS packages too'
+ type: boolean
+ default: true
permissions:
contents: read
@@ -100,16 +109,9 @@ jobs:
if: ${{ !cancelled() }}
strategy:
fail-fast: false
+ # The Linux packages, plus the macOS ones unless the caller leaves them out.
matrix:
- include:
- - runner: ubuntu-24.04
- rid: linux-x64
- - runner: ubuntu-24.04-arm
- rid: linux-arm64
- - runner: macos-15
- rid: osx-arm64
- - runner: macos-15-intel
- rid: osx-x64
+ include: ${{ fromJSON(inputs.macos == false && '[{"runner":"ubuntu-24.04","rid":"linux-x64"},{"runner":"ubuntu-24.04-arm","rid":"linux-arm64"}]' || '[{"runner":"ubuntu-24.04","rid":"linux-x64"},{"runner":"ubuntu-24.04-arm","rid":"linux-arm64"},{"runner":"macos-15","rid":"osx-arm64"},{"runner":"macos-15-intel","rid":"osx-x64"}]') }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
defaults: