Skip to content
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

introduce M1 Mac #1746

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/build-openssl-darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@ PERL_DIR=$PERL_VERSION
if [[ "x$PERL_MULTI_THREAD" != "x" ]]; then
PERL_DIR="$PERL_DIR-thr"
fi
PREFIX=$RUNNER_TOOL_CACHE/perl/$PERL_DIR/x64

case $(uname -m) in
"x86_64")
ARCH=x64;;
"aarch64")
ARCH=arm64;;
*)
echo "unknown architecture: $(uname -m)"
shogo82148 marked this conversation as resolved.
Show resolved Hide resolved
esac
shogo82148 marked this conversation as resolved.
Show resolved Hide resolved
PREFIX=$RUNNER_TOOL_CACHE/perl/$PERL_DIR/$ARCH

# detect the number of CPU Core
JOBS=$(sysctl -n hw.logicalcpu_max)
Expand Down
167 changes: 167 additions & 0 deletions .github/workflows/darwin-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
name: build on darwin-arm64

on:
pull_request:
paths:
- "versions/darwin.json"
- "scripts/darwin/**"
- "scripts/lib/Devel/**"
- ".github/workflows/darwin-arm64.yml"
- ".github/build-openssl-darwin.sh"
push:
branches:
- "releases/*"
schedule:
- cron: "10 15 * * 5"
workflow_dispatch:
inputs:
perl-versions:
description: perl versions to build (JSON Array)
required: false
default: ""

jobs:
list:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: set-matrix
name: list available perl versions
run: |
if [ -n "$PERL_VERSIONS" ]; then
echo "matrix=$(printenv PERL_VERSIONS | jq -c '{perl: .}')" >> "$GITHUB_OUTPUT"
else
echo "matrix=$(<versions/darwin.json jq -c '{perl: .}')" >> "$GITHUB_OUTPUT"
fi
env:
PERL_VERSIONS: ${{ github.event.inputs.perl-versions }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

sanity-check:
runs-on: macos-14
steps:
- id: perl
name: check pre-installed perl version
run: |
perl -e 'print "version=$^V\n"' >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: scripts/darwin/local
key: Darwin-sanity-check-perl-${{ steps.perl.outputs.version }}-${{ hashFiles('scripts/darwin/cpanfile.snapshot') }}
restore-keys: Darwin-sanity-check-perl-${{ steps.perl.outputs.version }}-
- name: sanity check
run: |
../../bin/carton install --deployment
../../bin/carton exec perl -c build.pl
../../bin/carton exec perl -I../lib -c ../lib/Devel/PatchPerl/Plugin/GitHubActions.pm
../../bin/carton exec perl -I../lib -c ../lib/Devel/PatchPerl/Plugin/MinGW.pm
../../bin/carton exec perl -I../lib -c ../lib/Devel/PatchPerl/Plugin/MinGWGNUmakefile.pm
working-directory: ./scripts/darwin
env:
PERL5LIB: ${{ github.workspace }}/scripts/lib

build:
runs-on: macos-14
needs:
- sanity-check
- list
timeout-minutes: 120
strategy:
fail-fast: false
matrix: ${{fromJson(needs.list.outputs.matrix)}}
env:
PERL_VERSION: ${{ matrix.perl }}
steps:
- uses: actions/checkout@v4
- id: perl
name: setup host perl
run: |
perl -MConfig -E 'say "$Config{bin}"' >> "$GITHUB_PATH"
perl -e 'print "version=$^V\n"' >> "$GITHUB_OUTPUT"
- name: Host perl -V
run: perl -V
- name: gcc --version
run: gcc --version

- name: build OpenSSL
run: .github/build-openssl-darwin.sh

- uses: actions/cache@v4
with:
path: scripts/darwin/local
key: ${{ runner.os }}-${{ runner.arch }}-build-perl-${{ steps.perl.outputs.version }}-${{ hashFiles('scripts/darwin/cpanfile.snapshot') }}
restore-keys: ${{ runner.os }}-build-perl-${{ steps.perl.outputs.version }}-
- name: carton install --deployment
shell: bash
run: ../../bin/carton install --deployment
working-directory: ./scripts/darwin

- name: build
shell: bash
run: perl build.pl
env:
PERL5LIB: ${{ github.workspace }}/scripts/darwin/local/lib/perl5
working-directory: ./scripts/darwin

- name: upload
run: |
ACTIONS_VERSION=v$(<"$GITHUB_WORKSPACE/package.json" jq -r .version)
mv "$RUNNER_TEMP/perl.tar.zstd" "$RUNNER_TEMP/perl-$PERL_VERSION-darwin-arm64.tar.zstd"
gh release upload --clobber "$ACTIONS_VERSION" "$RUNNER_TEMP/perl-$PERL_VERSION-darwin-arm64.tar.zstd"
env:
GITHUB_TOKEN: ${{ github.token }}

build-multi-thread:
runs-on: macos-14
needs:
- sanity-check
- list
timeout-minutes: 120
strategy:
fail-fast: false
matrix: ${{fromJson(needs.list.outputs.matrix)}}
env:
PERL_VERSION: ${{ matrix.perl }}
PERL_MULTI_THREAD: "1"
steps:
- uses: actions/checkout@v4
- id: perl
name: setup host perl
run: |
perl -MConfig -E 'say "$Config{bin}"' >> "$GITHUB_PATH"
# shellcheck disable=SC2016
perl -e 'print "version=$^V\n"' >> "$GITHUB_OUTPUT"
- name: Host perl -V
run: perl -V
- name: gcc --version
run: gcc --version

- name: build OpenSSL
run: .github/build-openssl-darwin.sh

- uses: actions/cache@v4
with:
path: scripts/darwin/local
key: ${{ runner.os }}-${{ runner.arch }}-build-perl-${{ steps.perl.outputs.version }}-${{ hashFiles('scripts/darwin/cpanfile.snapshot') }}
restore-keys: ${{ runner.os }}-build-perl-${{ steps.perl.outputs.version }}-
- name: carton install --deployment
shell: bash
run: ../../bin/carton install --deployment
working-directory: ./scripts/darwin

- name: build
shell: bash
run: perl build.pl
env:
PERL5LIB: ${{ github.workspace }}/scripts/darwin/local/lib/perl5
working-directory: ./scripts/darwin

- name: upload
run: |
ACTIONS_VERSION=v$(<"$GITHUB_WORKSPACE/package.json" jq -r .version)
mv "$RUNNER_TEMP/perl.tar.zstd" "$RUNNER_TEMP/perl-$PERL_VERSION-darwin-arm64-multi-thread.tar.zstd"
gh release upload --clobber "$ACTIONS_VERSION" "$RUNNER_TEMP/perl-$PERL_VERSION-darwin-arm64-multi-thread.tar.zstd"
env:
GITHUB_TOKEN: ${{ github.token }}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: build on darwin
name: build on darwin-x64

on:
pull_request:
paths:
- "versions/darwin.json"
- "scripts/darwin/**"
- "scripts/lib/Devel/**"
- ".github/workflows/darwin.yml"
- ".github/workflows/darwin-x64.yml"
- ".github/build-openssl-darwin.sh"
push:
branches:
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

sanity-check:
runs-on: macos-latest
runs-on: macos-11
steps:
- id: perl
name: check pre-installed perl version
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
- uses: actions/cache@v4
with:
path: scripts/darwin/local
key: ${{ runner.os }}-build-perl-${{ steps.perl.outputs.version }}-${{ hashFiles('scripts/darwin/cpanfile.snapshot') }}
key: ${{ runner.os }}-${{ runner.arch }}-build-perl-${{ steps.perl.outputs.version }}-${{ hashFiles('scripts/darwin/cpanfile.snapshot') }}
restore-keys: ${{ runner.os }}-build-perl-${{ steps.perl.outputs.version }}-
- name: carton install --deployment
shell: bash
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
- uses: actions/cache@v4
with:
path: scripts/darwin/local
key: ${{ runner.os }}-build-perl-${{ steps.perl.outputs.version }}-${{ hashFiles('scripts/darwin/cpanfile.snapshot') }}
key: ${{ runner.os }}-${{ runner.arch }}-build-perl-${{ steps.perl.outputs.version }}-${{ hashFiles('scripts/darwin/cpanfile.snapshot') }}
restore-keys: ${{ runner.os }}-build-perl-${{ steps.perl.outputs.version }}-
- name: carton install --deployment
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ jobs:
fail-fast: false
matrix:
os:
- macos-14
- macos-13
- macos-12
- macos-11
Expand Down
10 changes: 9 additions & 1 deletion scripts/darwin/build.pl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@
}
$runner_tool_cache = $cache;
}
chomp (my $arch = `uname -m`);
if ($arch eq 'x86_64') {
$arch = 'x64';
} elsif ($arch eq 'aarch64') {
$arch = 'arm64';
} else {
die "unsupported arch: $arch";
shogo82148 marked this conversation as resolved.
Show resolved Hide resolved
}
shogo82148 marked this conversation as resolved.
Show resolved Hide resolved
my $install_dir = File::Spec->rel2abs(
File::Spec->catdir($runner_tool_cache, "perl", $version . ($thread ? "-thr" : ""), "x64"));
File::Spec->catdir($runner_tool_cache, "perl", $version . ($thread ? "-thr" : ""), $arch));
my $perl = File::Spec->catfile($install_dir, 'bin', 'perl');

# read cpanfile snapshot
Expand Down
Loading