Skip to content

Commit

Permalink
ci: Add and use setup-libmagic Action
Browse files Browse the repository at this point in the history
Signed-off-by: robot9001 <robo9k@symlink.io>
  • Loading branch information
robo9k committed Oct 7, 2023
1 parent 72095d4 commit 22cf8d3
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 8 deletions.
68 changes: 68 additions & 0 deletions .github/actions/setup-libmagic/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: setup-libmagic
description: Setup some version of `libmagic` for `magic-sys`

runs:
using: 'composite'
steps:
# setup cache
- name: setup cache
if: ${{ runner.os == 'Windows' }}
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
# update packages

- name: update packages
if: ${{ runner.os == 'Linux' }}
run: sudo apt-get update
shell: bash

- name: update packages
if: ${{ runner.os == 'Windows' }}
run: vcpkg update
shell: bash

- name: update packages
if: ${{ runner.os == 'macOS' }}
run: brew update
shell: bash


# install packages

- name: install packages
if: ${{ runner.os == 'Linux' }}
run: sudo apt-get install libmagic1 libmagic-dev pkg-config
shell: bash

- name: install packages
if: ${{ runner.os == 'Windows' }}
run: vcpkg install libmagic
shell: bash

- name: install packages
if: ${{ runner.os == 'macOS' }}
run: brew install libmagic pkg-config
shell: bash


# setup environment

- name: setup environment
if: ${{ runner.os == 'Linux' }}
run: echo "VCPKGRS_NO_LIBMAGIC=1" >> "${GITHUB_ENV}"
shell: bash

- name: setup environment
if: ${{ runner.os == 'Windows' }}
run: echo "LIBMAGIC_NO_PKG_CONFIG=1" >> "${GITHUB_ENV}"
shell: bash

- name: setup environment
if: ${{ runner.os == 'macOS' }}
run: echo "VCPKGRS_NO_LIBMAGIC=1" >> "${GITHUB_ENV}"
shell: bash
1 change: 1 addition & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup-libmagic
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: brew
run: |
brew update
brew install libmagic
- uses: ./.github/actions/setup-libmagic
- name: install Rust MSRV
uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
with:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: vcpkg
run: |
cargo +stable install cargo-vcpkg
cargo vcpkg build
- uses: ./.github/actions/setup-libmagic
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down

0 comments on commit 22cf8d3

Please sign in to comment.