thorvg/.github/workflows/build_macos.yml
Josh Soref 2fa723c947 infra/workflow: Reduce workflow permissions
By explicitly listing the permissions required in general, repositories
without restrictive permissions will only allocate the specified
permissions which is much safer than the default, fairly wide,
permissions grant.

Most workflows don't appear to need any permissions beyond
`contents: read` which is required for checkout (when a repository is
private). By specifying this permission, it tells GitHub not to include
any of its additional default permissions (when a repository is
configured permissively).

The .github/workflows/memcheck_*.sh scripts called by build_ubuntu.yml
require write permissions in order to post their output to a pull
request (as a comment).

In locked down GitHub repositories, unless a workflow/job asks for
write permissions, it will not have them and such API calls will result
in:

{
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/issues/comments#create-an-issue-comment",
  "status": "403"
}

By specifically requesting the permissions, the workflow will continue
to work as expected.
2024-09-30 12:46:24 +09:00

88 lines
2.3 KiB
YAML

name: macOS
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions:
contents: read
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Unbreak Python in GitHub Actions
run: |
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
sudo rm -rf /Library/Frameworks/Python.framework/
brew install --force python3 && brew unlink python3 && brew link --overwrite python3
- name: Install Packages
run: |
export HOMEBREW_NO_INSTALL_FROM_API=1
brew update
brew install meson efl
- name: Build
run: |
meson setup build -Dlog=true -Dexamples=true -Dloaders=all -Dsavers=all -Dbindings=capi -Dtools=all
ninja -C build install
compact_test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Unbreak Python in GitHub Actions
run: |
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
sudo rm -rf /Library/Frameworks/Python.framework/
brew install --force python3 && brew unlink python3 && brew link --overwrite python3
- name: Install Packages
run: |
brew update
brew install meson
- name: Build
run: |
meson setup build -Dlog=true -Dloaders=all -Dsavers=all -Dstatic=true -Dthreads=false
ninja -C build install
unit_test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Unbreak Python in GitHub Actions
run: |
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
sudo rm -rf /Library/Frameworks/Python.framework/
brew install --force python3 && brew unlink python3 && brew link --overwrite python3
- name: Install Packages
run: |
brew update
brew install meson
- name: Build
run: |
meson setup build -Dloaders=all -Dsavers=all -Dbindings=capi -Dtests=true --errorlogs
ninja -C build install test
- uses: actions/upload-artifact@v4
with:
name: UnitTestReport
path: build/meson-logs/testlog.txt