Skip to content

Commit 96043e4

Browse files
committed
Add some optional arguments to install modules
You can now in addition to install cpm also install some modules. Fix: #1, #2, #4
1 parent 2787fb2 commit 96043e4

File tree

6 files changed

+430
-28
lines changed

6 files changed

+430
-28
lines changed

.github/workflows/check.yml

Lines changed: 132 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,137 @@ name: check
33
on: [push]
44

55
jobs:
6-
testing:
6+
7+
# note using ./ is a trick to be sure to use @master
8+
# otherwise it can be delayed...
9+
# we cannot use
10+
#
11+
# perl-actions/install-cpm@master
12+
# perl-actions/install-cpm@${{ github.sha }}
13+
#
14+
# https://github.community/t5/GitHub-Actions/Usage-of-expressions-and-contexts-in-uses-clause/m-p/39502#M3835
15+
16+
cpm:
17+
runs-on: ubuntu-latest
18+
name: 'install cpm'
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: uses install-cpm
22+
uses: ./
23+
- name: which cpm
24+
run: |
25+
which cpm
26+
cpm --version
27+
28+
cpm_version:
29+
runs-on: ubuntu-latest
30+
name: 'install cpm 0.990'
31+
steps:
32+
- uses: actions/checkout@v2
33+
- name: uses install-cpm
34+
uses: ./
35+
with:
36+
version: '0.990'
37+
- name: cpm --version
38+
run: |
39+
cpm --version
40+
41+
### Install a single module
42+
43+
one_module:
44+
runs-on: ubuntu-latest
45+
name: 'cpm and a module'
46+
steps:
47+
- uses: actions/checkout@v2
48+
- name: uses install-cpm
49+
uses: ./
50+
with:
51+
install: 'Simple::Accessor'
52+
53+
### Install multiple modules
54+
55+
multiple_modules:
56+
runs-on: ubuntu-latest
57+
name: 'cpm & modules'
58+
steps:
59+
- uses: actions/checkout@v2
60+
- name: uses install-cpm
61+
uses: ./
62+
with:
63+
install: |
64+
Simple::Accessor
65+
Test::Parallel
66+
67+
### Install modules from a cpanfile
68+
69+
cpanfile_root:
70+
runs-on: ubuntu-latest
71+
name: 'cpanfile as root'
72+
steps:
73+
- uses: actions/checkout@v2
74+
- name: 'Create a cpanfile'
75+
run: |
76+
echo "requires 'A1z::Html';" > cpanfile.test
77+
- name: uses install-cpm
78+
uses: ./
79+
with:
80+
cpanfile: 'cpanfile.test'
81+
82+
cpanfile_nonroot:
83+
runs-on: ubuntu-latest
84+
name: 'cpanfile non root'
85+
steps:
86+
- uses: actions/checkout@v2
87+
- name: 'Create a cpanfile'
88+
run: |
89+
echo "requires 'A1z::Html';" > cpanfile.test
90+
- name: uses install-cpm
91+
uses: ./
92+
with:
93+
cpanfile: 'cpanfile.test'
94+
sudo: false
95+
global: false
96+
path: 'cpm'
97+
98+
### Install a module and enable tests
99+
100+
with_tests:
101+
runs-on: ubuntu-latest
102+
name: 'install with tests'
103+
steps:
104+
- uses: actions/checkout@v2
105+
- name: uses install-cpm
106+
uses: ./
107+
with:
108+
install: 'Simple::Accessor'
109+
tests: true
110+
111+
### Install module(s) to local directory
112+
113+
local_install:
114+
runs-on: ubuntu-latest
115+
name: 'local installation non root'
116+
steps:
117+
- uses: actions/checkout@v2
118+
- name: uses install-cpm
119+
uses: ./
120+
with:
121+
install: 'Simple::Accessor'
122+
global: false
123+
sudo: false
124+
125+
### Use some custom args to install
126+
127+
with_args:
7128
runs-on: ubuntu-latest
8-
name: Testing GitHub action
129+
name: 'cpanfile with args'
9130
steps:
10-
- name: install-cpm
11-
uses: perl-actions/install-cpm@master
12-
- name: which cpm
13-
run: which cpm
131+
- uses: actions/checkout@v2
132+
- name: 'Create a cpanfile'
133+
run: |
134+
echo "requires 'A1z::Html';" > cpanfile.test
135+
- name: uses install-cpm
136+
uses: ./
137+
with:
138+
cpanfile: 'cpanfile.test'
139+
args: '--with-recommends --with-suggests'

README.md

Lines changed: 115 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,126 @@ This action installs 'cpm' as root so you can then use it in your workflow.
88

99
## Inputs
1010

11-
none
11+
### `install`
12+
13+
List of one or more modules, separated by a newline `\n` character.
14+
15+
### `cpanfile`
16+
17+
Install modules from a cpanfile.
18+
19+
### `tests`
20+
21+
Boolean variable used to disable unit tests during installation
22+
Possible values: true | false [default: false]
23+
24+
### `global`
25+
26+
Boolean variable used to install or not modules to @INC instead of local.
27+
This variable controls the `-g` option from cpm and is enabled by default.
28+
29+
Possible values: true | false [default: true]
30+
31+
### `args`
32+
33+
Extra arguments to pass to the cplay command line.
34+
35+
### `sudo`
36+
37+
Run commands as sudo: true | false [default: true]
38+
39+
### `perl`
40+
41+
Which perl path to use. Default to use `perl` from the current `PATH`.
42+
43+
### `path`
44+
45+
Where to install `cpm`. Default value is `$Config{installsitescript}/cpm`.
46+
47+
### `version`
48+
49+
Which version/tag of `cpm` to install. Default is 'master' to use the latest version.
1250

1351
## Outputs
1452

1553
none
1654

1755
## Example usage
1856

57+
### Install cpm
58+
59+
Just install cpm without running any install commands.
60+
You can then use cpm yourself in order commands.
61+
62+
```yaml
63+
- name: install cpm
64+
uses: perl-actions/install-cpm@v1.1
65+
# then you can use it
66+
- run: 'sudo cpm install -g Simple::Accessor'
67+
```
68+
69+
### Install a single module
70+
71+
```yaml
72+
- name: install cpm and one module
73+
uses: perl-actions/install-cpm@v1.1
74+
with:
75+
install: 'Simple::Accessor'
76+
```
77+
78+
### Install multiple modules
79+
80+
List modules seperated by a newline character `\n`
81+
82+
```yaml
83+
- name: install cpm and multiple modules
84+
uses: perl-actions/install-cpm@v1.1
85+
with:
86+
install: |
87+
Simple::Accessor
88+
Test::Parallel
89+
```
90+
91+
### Install modules from a cpanfile
92+
93+
```yaml
94+
- name: install cpm and files from cpanfile
95+
uses: perl-actions/install-cpm@v1.1
96+
with:
97+
cpanfile: 'your-cpanfile'
98+
```
99+
100+
### Install a module and enable tests
101+
102+
Install modules with tests.
103+
104+
```yaml
105+
- name: install cpm and files from cpanfile
106+
uses: perl-actions/install-cpm@v1.1
107+
with:
108+
install: 'Simple::Accessor'
109+
tests: true
110+
```
111+
112+
### Install module(s) to local directory
113+
114+
Disable the `-g` flag.
115+
116+
```yaml
117+
- name: install cpm and files from cpanfile
118+
uses: perl-actions/install-cpm@v1.1
119+
with:
120+
install: 'Simple::Accessor'
121+
global: false
122+
sudo: false
123+
```
124+
125+
### Use some custom args to install
126+
127+
```yaml
128+
- name: 'install cpm + cpanfile with args'
129+
uses: perl-actions/install-cpm@v1.1
130+
with:
131+
cpanfile: 'your-cpanfile'
132+
args: '--with-recommends --with-suggests'
19133
```
20-
uses: perl-actions/install-cpm@v1.0
21-
run: |
22-
sudo cpm install -g Module::To::Install
23-
```

action.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,50 @@ description: 'install App::cpm'
33
branding:
44
icon: 'arrow-right'
55
color: 'blue'
6+
inputs:
7+
8+
install:
9+
description: 'List of modules or distributions to install [seperated by newline]'
10+
required: false
11+
12+
cpanfile:
13+
description: 'Use a cpanfile to install modules'
14+
required: false
15+
16+
tests:
17+
description: 'Run or not the unit tests'
18+
required: false
19+
default: false
20+
21+
global:
22+
description: 'Perform a global or local installation: -g'
23+
required: false
24+
default: true
25+
26+
args:
27+
description: 'Extra args used passed to install command'
28+
required: false
29+
30+
sudo:
31+
description: 'Perform installations as root'
32+
required: false
33+
default: true
34+
35+
perl:
36+
description: 'Path of perl to use default to currtent PATH'
37+
required: false
38+
default: 'perl'
39+
40+
path:
41+
description: 'Path where to install cpm: the string can use $Config values'
42+
required: false
43+
default: "$Config{installsitescript}/cpm"
44+
45+
version:
46+
description: 'Which version to install'
47+
required: false
48+
default: 'master'
49+
650
runs:
751
using: 'node12'
852
main: 'index.js'

0 commit comments

Comments
 (0)