From c8bc4fac799cf3f7da630c602decfe84a485df35 Mon Sep 17 00:00:00 2001 From: Sanko Robinson Date: Sat, 14 Sep 2024 15:04:28 -0400 Subject: [PATCH] Swap GHA system --- .github/workflows/bsd.yml | 47 --------- .github/workflows/ci.yml | 154 +++++++++++++++++++++++++++++ .github/workflows/delete_cache.yml | 28 ++++++ .github/workflows/linux.yml | 22 ----- .github/workflows/macos.yml | 24 ----- .github/workflows/windows.yml | 28 ------ .gitignore | 1 + META.json | 2 +- builder/xmake.pm | 9 +- lib/Alien/xmake.pm | 22 ++--- t/00_compile.t | 10 +- 11 files changed, 201 insertions(+), 146 deletions(-) delete mode 100644 .github/workflows/bsd.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/delete_cache.yml delete mode 100644 .github/workflows/linux.yml delete mode 100644 .github/workflows/macos.yml delete mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/bsd.yml b/.github/workflows/bsd.yml deleted file mode 100644 index 05bd699..0000000 --- a/.github/workflows/bsd.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: BSD -on: [push, pull_request, workflow_dispatch] -jobs: - test: - runs-on: ubuntu-latest - name: ${{ matrix.os.name }} - strategy: - fail-fast: false - matrix: - os: - - name: freebsd - architecture: x86-64 - version: '14.0' - pkg: sudo pkg install -y perl5 - - #~ - name: netbsd - #~ architecture: x86-64 - #~ version: '9.3' - #~ # https://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/perl5/index.html - #~ pkg: sudo pkgin -y install perl-5.38.2 - - steps: - - uses: actions/checkout@v4 - - name: Test on ${{ matrix.os.name }} - uses: cross-platform-actions/action@v0.23.0 - env: - MY_ENV1: MY_ENV1 - MY_ENV2: MY_ENV2 - with: - environment_variables: MY_ENV1 MY_ENV2 - operating_system: ${{ matrix.os.name }} - architecture: ${{ matrix.os.architecture }} - version: ${{ matrix.os.version }} - shell: bash - memory: 5G - cpu_count: 4 - run: | - uname -a - echo $SHELL - pwd - ls -lah - whoami - env | sort - ${{ matrix.os.pkg }} p5-App-cpanminus git gmake - perl -V - gmake -v - cpanm -v --mirror http://cpan.cpantesters.org/ . diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e3f4b28 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,154 @@ +--- +jobs: + etc: + name: 'Other Platforms/v${{matrix.perl}}' + needs: + - setup + strategy: + fail-fast: false + matrix: + os: + - architecture: x86-64 + host: ubuntu-20.04 + name: freebsd + pkg: pkg install -y + version: 13.2 + - architecture: arm64 + host: ubuntu-20.04 + name: freebsd + pkg: pkg install -y + version: 13.2 + perl: + - 5.38 + max-parallel: 25 + uses: sanko/actions/.github/workflows/affix-cross.yml@main + with: + arch: '${{ matrix.os.architecture }}' + host: '${{ matrix.os.host }}' + os: '${{ matrix.os.name }}' + perl: '${{ matrix.perl }}' + pkg: '${{ matrix.os.pkg }}' + version: '${{ matrix.os.version }}' + linux: + name: 'Linux/v${{matrix.perl}}' + needs: + - setup + strategy: + fail-fast: false + matrix: + flags: + - '' + - -Dusethreads + - -Duselongdouble + - -Dusequadmath + os: + - ubuntu-22.04 + perl: '${{ fromJSON(needs.setup.outputs.matrix).perl }}' + max-parallel: 25 + uses: sanko/actions/.github/workflows/affix-unix.yml@main + with: + flags: '${{ matrix.flags }}' + os: '${{ matrix.os }}' + perl: '${{ matrix.perl }}' + macos: + name: "[${{ matrix.os == 'macos-14' && 'M1' || 'Intel' }}] macOS/v${{matrix.perl}}" + needs: + - setup + strategy: + fail-fast: false + matrix: + exclude: + - flags: -Dusequadmath + - flags: -Dusethreads + flags: '${{ fromJSON(needs.setup.outputs.matrix).flags }}' + os: + - macos-14 + - macos-latest + perl: '${{ fromJSON(needs.setup.outputs.matrix).perl }}' + max-parallel: 25 + uses: sanko/actions/.github/workflows/affix-unix.yml@main + with: + flags: '${{ matrix.flags }}' + os: '${{ matrix.os }}' + perl: '${{ matrix.perl }}' + results: + name: Results + needs: + - macos + - win32 + - linux + runs-on: ubuntu-22.04 + steps: + - name: Download test results + uses: actions/download-artifact@v4 + with: + path: artifacts + - name: Report test results + run: | + # Function to process a directory + process_dir() { + local dir="$1" + # Loop through each element in the directory + for file in "$dir"/*; do + # Check if it's a directory + if [ -d "$file" ]; then + # Recursively call process_dir for subdirectories (except .) + if [ "$file" != "." ]; then + process_dir "$file" + fi + # If it's a regular file, print its content + elif [ -f "$file" ]; then + echo "================> $file <================" + cat "$file" + echo "" # Add an empty line between files + fi + done + } + # Get the directory path from the first argument (or current directory) + dir=${1:-.} + # Process the specified directory + process_dir "artifacts" + setup: + name: Generate Testing Matrix + outputs: + matrix: '${{ steps.matrix.outputs.matrix }}' + runs-on: ubuntu-22.04 + steps: + - env: + DATA: | + { + "perl": ["5.38.2", "5.40.0"], + "flags": ["", "-Dusethreads", "-Duselongdouble", "-Dusequadmath"] + } + id: matrix + run: "jq -rn 'env.DATA | fromjson | @json \"matrix=\\(.)\"' > $GITHUB_OUTPUT\n" + win32: + name: 'Windows/v${{matrix.perl}}' + needs: + - setup + strategy: + fail-fast: false + matrix: + exclude: + - perl: 5.40.0 + - flags: -Duselongdouble + - flags: -Dusequadmath + flags: + - -Dusethreads + - '' + os: + - windows-2022 + perl: '${{ fromJSON(needs.setup.outputs.matrix).perl }}' + max-parallel: 25 + uses: sanko/actions/.github/workflows/affix-win32.yml@main + with: + flags: '${{ matrix.flags }}' + os: '${{ matrix.os }}' + perl: '${{ matrix.perl }}' +name: CI Matrix +on: + pull_request: ~ + push: ~ + schedule: + - cron: 42 5 * * 0 + workflow_dispatch: ~ diff --git a/.github/workflows/delete_cache.yml b/.github/workflows/delete_cache.yml new file mode 100644 index 0000000..20e4b2d --- /dev/null +++ b/.github/workflows/delete_cache.yml @@ -0,0 +1,28 @@ +--- +jobs: + clear-cache: + runs-on: ubuntu-latest + steps: + - name: 'Clear cache [https://stackoverflow.com/a/73556714]' + uses: actions/github-script@v7 + with: + script: | + console.log("About to clear") + const caches = await github.rest.actions.getActionsCacheList({ + owner: context.repo.owner, + repo: context.repo.repo, + }) + for (const cache of caches.data.actions_caches) { + console.log(cache) + github.rest.actions.deleteActionsCacheById({ + owner: context.repo.owner, + repo: context.repo.repo, + cache_id: cache.id, + }) + } + console.log("Clear completed") +name: Clear cache +on: + workflow_dispatch: ~ +permissions: + actions: write diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml deleted file mode 100644 index af26713..0000000 --- a/.github/workflows/linux.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Linux -on: [push, pull_request, workflow_dispatch] -jobs: - build: - runs-on: "${{ matrix.os }}-latest" - strategy: - fail-fast: false - matrix: - os: - - ubuntu - perl: - - 5.38 - - 5.36 - name: ${{ matrix.os }}/${{ matrix.perl }} - steps: - - uses: actions/checkout@v4 - - name: Setup perl - uses: shogo82148/actions-setup-perl@v1 - with: - perl-version: ${{ matrix.perl }} - - name: Run tests - run: cpanm --test-only -v . diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index d95b66d..0000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: macOS -on: [push, pull_request, workflow_dispatch] -jobs: - build: - runs-on: "${{ matrix.os }}-latest" - strategy: - fail-fast: false - matrix: - os: - - macos - perl: - - 5.38 - - 5.36 - name: ${{ matrix.os }}/${{ matrix.perl }} - steps: - - uses: actions/checkout@v4 - - name: Setup perl - uses: shogo82148/actions-setup-perl@v1 - with: - perl-version: ${{ matrix.perl }} - - name: Build with cpam - run: cpanm --installdeps --notest . - - name: Run tests - run: cpanm --test-only -v . diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index a67a105..0000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Windows -on: [push, pull_request, workflow_dispatch] -jobs: - build: - runs-on: "${{ matrix.os }}-latest" - strategy: - fail-fast: false - matrix: - os: - - windows - perl: - - 5.38 - - 5.36 - flavor: - - strawberry - - default - name: ${{ matrix.os }}/${{ matrix.perl }}/${{ matrix.flavor }} - steps: - - uses: actions/checkout@v4 - - name: Setup perl - uses: shogo82148/actions-setup-perl@v1 - with: - perl-version: ${{ matrix.perl }} - distribution: ${{ matrix.flavor }} - - name: Install prereqs - run: cpanm --installdeps -n -v . - - name: Run tests - run: cpanm --test-only -v . diff --git a/.gitignore b/.gitignore index 0e83579..07af4ac 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ share/share share/bin *.session xmake.* +.xmake/* diff --git a/META.json b/META.json index b7f7944..f44e162 100644 --- a/META.json +++ b/META.json @@ -5,7 +5,7 @@ "Sanko Robinson " ], "dynamic_config" : 0, - "generated_by" : "Minilla/v3.1.23, CPAN::Meta::Converter version 2.150010", + "generated_by" : "Minilla/v3.1.25, CPAN::Meta::Converter version 2.150010", "license" : [ "artistic_2" ], diff --git a/builder/xmake.pm b/builder/xmake.pm index 3860d67..b23f6ee 100644 --- a/builder/xmake.pm +++ b/builder/xmake.pm @@ -12,7 +12,7 @@ package builder::xmake { use Archive::Tar qw[]; use Path::Tiny qw[path]; # - my $version = '2.8.8'; # Target install version + my $version = '2.9.5'; # Target install version my $installer_exe # Pretend we're 64bit = "https://github.com/xmake-io/xmake/releases/download/v${version}/xmake-v${version}.win64.exe"; my $installer_tar @@ -75,6 +75,7 @@ package builder::xmake { $s->config_data( xrepo_exe => $xrepo ); $s->config_data( xmake_dir => File::Basename::dirname($xmake) ); my $run = `$xmake --version`; + warn $run; my ($ver) = $run =~ m[xmake (v.+?), A cross-platform build utility based on Lua]; $s->config_data( xmake_ver => $ver ); $s->config_data( xmake_installed => 1 ); @@ -83,9 +84,10 @@ package builder::xmake { # Module::Build subclass sub ACTION_xmake_install { my ($s) = @_; + use Data::Dump; + ddx { $s->config_data }; - #~ ddx $s->config_data; - return $s->config_data('xmake_type') if $s->config_data('xmake_type'); + #~ return $s->config_data('xmake_type') if $s->config_data('xmake_type'); # my $os = $s->os_type; # based on Perl::OSType if ( !defined $os ) { @@ -147,6 +149,7 @@ package builder::xmake { sub ACTION_code { my ($s) = @_; + warn 'CODE'; $s->depends_on('xmake_install'); $s->SUPER::ACTION_code; } diff --git a/lib/Alien/xmake.pm b/lib/Alien/xmake.pm index ea0558e..6a0714c 100644 --- a/lib/Alien/xmake.pm +++ b/lib/Alien/xmake.pm @@ -4,15 +4,12 @@ package Alien::xmake 0.05 { use Path::Tiny qw[path]; # my $Windows = $^O eq 'MSWin32'; - my ($dir) = - - my @dirs = - grep {defined} map { - my $path = path($_)->child( grep {defined} qw[auto share dist Alien-xmake], $Windows ? () : 'bin' ); + my ($dir) = my @dirs = grep {defined} map { + my $path = path($_) + ->child( grep {defined} qw[auto share dist Alien-xmake], $Windows ? () : 'bin' ); $path->is_dir ? $path : () - } @INC; - -warn $_ for @dirs; + } grep {defined} @INC, config()->{xmake_dir}; + warn $_ for @dirs; # sub config { CORE::state $config //= sub { @@ -38,17 +35,16 @@ warn $_ for @dirs; sub bin_dir { $dir // return; $dir->child('bin')->canonpath; } sub exe { - $dir // return; - $dir->child( 'bin', 'xmake' . ( $Windows ? '.exe' : '' )->canonpath ); + config()->{xmake_exe} + // $dir->child( 'bin', 'xmake' . ( $Windows ? '.exe' : '' )->canonpath ); } sub xrepo { - $dir // return; - $dir->child( 'bin', 'xrepo' . ( $Windows ? '.bat' : '' )->canonpath ); + config()->{xrepo_exe} + // $dir->child( 'bin', 'xrepo' . ( $Windows ? '.bat' : '' )->canonpath ); } sub version { - $dir // return; CORE::state $ver; if ( !defined $ver ) { my $xmake = exe(); diff --git a/t/00_compile.t b/t/00_compile.t index eec802d..65e390b 100644 --- a/t/00_compile.t +++ b/t/00_compile.t @@ -24,19 +24,13 @@ diag 'Install type: ' . Alien::xmake->install_type; subtest xmake => sub { my $exe = Alien::xmake->exe; diag 'Path to exe: ' . $exe; - ok $exe, 'xmake is installed as ' . $exe; - diag 'Running `xmake --version`'; - my $run = `$exe --version`; - ok $run, $run; + ok `$exe --version`, $exe . ' --version'; }; # subtest xrepo => sub { my $exe = Alien::xmake->xrepo; diag 'Path to exe: ' . $exe; - ok $exe, 'xrepo is installed as ' . $exe; - diag 'Running `xrepo --version`'; - my $run = `$exe --version`; - ok $run, $run; + ok `$exe --version`, $exe . ' --version'; }; ok( Alien::xmake->version, Alien::xmake->version ); #