Skip to content

Commit

Permalink
add install-modules option (#686)
Browse files Browse the repository at this point in the history
* add `install-modules` option

* implement installing with cpanm

* install extra modules

* add working-directory option

* add tests for instaling CPAN modules

* fix the name of option

* move the test to another workflow

* fix the name of steps

* configure environment values

* set full path for cpanm

* trim module names

* install App::a2p instead of Module::CPANfile

* fix module name

* add installers to the build matrix

* fix the name of the workflow

* enable caching npm modules

* fix the job name

* save cache

* implement installing with cpm

* bump cache version

* implement installWithCarton

* use perl installed

* add missing await

* add --show-build-log-on-failure option

* specify env

* skip test of old perl

* check whether cpanfile exists
  • Loading branch information
shogo82148 committed May 5, 2021
1 parent a3d77a0 commit 000f3d5
Show file tree
Hide file tree
Showing 14 changed files with 1,302 additions and 152 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/test-cpan-installer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CPAN installer
on:
pull_request:
paths:
- "bin/cpanm"
- "bin/cpm"
- "bin/carton"
- "__test__/**"
- "src/**"
- "package.json"
- "package-lock.json"
- "action.yml"
push:
branches:
- "main"
workflow_dispatch:

jobs:
installer:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
installer:
- cpanm
- cpm
- carton
perl:
- "5" # latest version of Perl 5

# TODO: fix cpm
# - "5.8.1" # oldest version the original cpanm supports
# TODO: @shogo82148 fix me
# building ExtUtils::MakeMaker fails.
# - "5.8.0"
# TODO: fix cpm
# - "5.6.2"
# - "5.6.1" # oldest version the action supports
# too old to work cpanm... I gave up.
# - "5.6.0"
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run build
- run: npm run package

- name: use the action
uses: ./
with:
perl-version: "${{ matrix.perl }}"
install-modules-with: "${{ matrix.installer }}"
install-modules: |
ExtUtils::MakeMaker
working-directory: __test__/p5-Test-Module
- name: print the version of App::a2p and use it
run: |
perl -MApp::a2p -e 'print $App::a2p::VERSION'
echo '$1' | a2p
- name: print the version of ExtUtils::MakeMaker
run: |
perl -MExtUtils::MakeMaker -e 'print $ExtUtils::MakeMaker::VERSION'
- run: ${{ matrix.installer }} --help
- run: ${{ matrix.installer }} --version
49 changes: 0 additions & 49 deletions .github/workflows/test-cpanm.yml

This file was deleted.

45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Main workflow
on:
pull_request:
paths:
- "__test__/**"
- "src/**"
- "package.json"
- "package-lock.json"
Expand Down Expand Up @@ -34,6 +35,17 @@ jobs:
with:
node-version: 12.x

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run build
- run: npm run package
Expand Down Expand Up @@ -107,6 +119,17 @@ jobs:
with:
node-version: 12.x

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run build
- run: npm run package
Expand Down Expand Up @@ -182,6 +205,17 @@ jobs:
with:
node-version: 12.x

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run build
- run: npm run package
Expand Down Expand Up @@ -257,6 +291,17 @@ jobs:
with:
node-version: 12.x

- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run build
- run: npm run package
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/node_modules/
/lib/
/__test__/runner/
local/
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ steps:
- uses: actions/checkout@v2
- uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.30'
perl-version: '5.32'
distribution: strawberry
- run: cpanm --installdeps .
- run: prove -lv t
Expand All @@ -66,7 +66,7 @@ This option is available on Windows and falls back to the default customized bin
The action works for [GitHub-hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners).

| Operating System | Supported Versions |
| --- | --- | --- |
| --- | --- |
| Linux | `ubuntu-18.04`, `ubuntu-20.04` |
| macOS | `macos-10.05`, `macos-11.0` |
| Windows | `windows-2019` |
Expand All @@ -82,6 +82,10 @@ All inputs are **optional**. If not set, sensible defaults will be used.
| `perl-version` | Specifies the Perl version to setup. Minor version and patch level can be omitted. The action uses the latest Perl version available that matches the specified value. This defaults to `5`, which results in the latest available version of Perl 5. In addition, the value `latest` is available, the actions uses the latest available version of Perl including `5`, `7` or later major versions. | `5` |
| `distribution` | Specify the distribution to use, this is either `default` or `strawberry`. (The value `strawberry` is ignored on anything but Windows.) | `default` |
| `multi-thread` | Enables interpreter-based threads (ithread) options (-Duseithreads). "true" and "false" are accepted. On Linux and macOS, the default value is "false" (ithread is disabled). On Windows, the default value is "true" (ithread is enable) for fork emulation. | depends on platform |
| `install-modules-with`| install CPAN modules from your `cpanfile` with the specified installer. `cpanm`([App::cpanminus](https://metacpan.org/pod/App::cpanminus)), `cpm`([App::cpm](https://metacpan.org/pod/App::cpm)), and `carton`([Carton](https://metacpan.org/pod/Carton)) are available. By default, any CPAN modules are not installed. | Nothing |
| `install-modules` | List of one or more CPAN modules, separated by a newline `\n` character. | Nothing |
| `enable-modules-cache` | enable caching when install CPAN modules. | `true` |
| `working-directory` | description: working directory. | `.` |

# Supported Shells

Expand Down
1 change: 1 addition & 0 deletions __test__/p5-Test-Module/cpanfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requires 'App::a2p';
23 changes: 22 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,40 @@ inputs:
perl-version:
description: "The Perl version to download (if necessary) and use. Example: 5.30.0"
default: "5"
required: false
distribution:
description: |
The distribution of Perl binary.
"default" and "strawberry" are accepted.
"default" is the custom binaries for actions-setup-perl. It is available on Linux, macOS, and Windows.
"strawberry" is from http://strawberryperl.com/ . It is available on Windows and falls back to default on other platform.
default: "default"
required: false
multi-thread:
description: |
enables multi threading options(-Duseshrplib -Duseithreads).
enables multi threading options(-Duseithreads).
"true" and "false" are accepted.
On Linux and macOS, the default value is false (multi threading is disabled).
On Windows, this option is ignored, multi-threading is always enabled.
required: false
install-modules-with:
description: |
install CPAN modules from your cpanfile with the specified installer.
cpanm(App::cpanminus), cpm(App::cpm), and carton(Carton) are available.
By default, any CPAN modules are not installed.
required: false
install-modules:
description: |
List of one or more CPAN modules, separated by a newline \n character.
required: false
enable-modules-cache:
description: enable caching when install CPAN modules.
default: true
required: false
working-directory:
description: working directory.
default: "."
required: false
runs:
using: "node12"
main: "dist/index.js"
Expand Down
Loading

0 comments on commit 000f3d5

Please sign in to comment.