Skip to content

Commit 781c691

Browse files
committed
Fixes to action code and update test workflow.
1 parent 0a71040 commit 781c691

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+9705
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on: [push]
2+
3+
jobs:
4+
Test:
5+
runs-on: ${{ matrix.os }}
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
os: [ubuntu-latest, macos-latest, windows-latest]
10+
use-bootstrap: [false, true]
11+
fpm-version: ['v0.1.0']
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
17+
- name: fpm-setup
18+
uses: ./ # Uses action in the root directory
19+
with:
20+
fpm-version: ${{ matrix.fpm-version }}
21+
use-bootstrap: ${{ matrix.use-bootstrap }}
22+
23+
- name: test fpm
24+
run: fpm --help
25+
26+
- name: Shell check (windows)
27+
if: contains(matrix.os, 'windows')
28+
run: |
29+
echo $ENV:PATH
30+
cmd /c where fpm
31+
fpm --help
32+
cmd /c fpm --help

action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'Setup fpm'
2+
description: 'Setup the Fortran Package Manager for use in Github actions CI'
3+
inputs:
4+
use-bootstrap:
5+
description: 'Whether to use the bootstrap implementation of fpm'
6+
required: false
7+
default: false
8+
fpm-version:
9+
description: 'The tag of an fpm release'
10+
required: false
11+
default: 'v0.1.0'
12+
fpm-repository:
13+
description: 'Github repository (url) serving fpm releases'
14+
required: false
15+
default: 'https://github.com/fortran-lang/fpm'
16+
runs:
17+
using: 'node12'
18+
main: 'index.js'

index.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
const core = require('@actions/core');
2+
const tc = require('@actions/tool-cache');
3+
const io = require('@actions/io');
4+
const exec = require('@actions/exec');
5+
const path = require('path');
6+
7+
// Main entry function
8+
//
9+
async function main(){
10+
11+
try {
12+
13+
// Get inputs
14+
const useBootstrap = core.getInput('use-bootstrap').toLowerCase() === 'true';
15+
console.log(`use-boostrap: ${useBootstrap}`);
16+
17+
const fpmVersion = core.getInput('fpm-version');
18+
console.log(`fpm-version: ${fpmVersion}`);
19+
20+
const fpmRepo = core.getInput('fpm-repository');
21+
console.log(`fpm-repository: ${fpmRepo}`);
22+
23+
// Build download path
24+
const fetchPath = fpmRepo + '/releases/download/' + fpmVersion + '/';
25+
const filename = getFPMFilename(useBootstrap,fpmVersion,process.platform);
26+
27+
console.log(`This platform is ${process.platform}`);
28+
console.log(`Fetching fpm from ${fetchPath}${filename}`)
29+
30+
// Download release
31+
var fpmPath;
32+
try {
33+
34+
fpmPath = await tc.downloadTool(fetchPath+filename);
35+
36+
} catch (error) {
37+
38+
core.setFailed(`Error while trying to fetch fpm - please check that a version exists at the above release url.`);
39+
40+
}
41+
42+
console.log(fpmPath);
43+
const downloadDir = path.dirname(fpmPath);
44+
45+
// Add executable flag on unix
46+
if (process.platform === 'linux' || process.platform === 'darwin'){
47+
48+
await exec.exec('chmod u+x '+fpmPath);
49+
50+
}
51+
52+
// Rename to 'fpm'
53+
await io.mv(fpmPath, downloadDir + '/' + 'fpm');
54+
55+
// Add to path
56+
core.addPath( downloadDir );
57+
console.log(`fpm added to path at ${downloadDir}`);
58+
59+
} catch (error) {
60+
61+
core.setFailed(error.message);
62+
63+
}
64+
};
65+
66+
67+
// Construct the filename for an fpm release
68+
//
69+
// fpm-[bootstrap-]<version>-<os>-<arch>[.exe]
70+
//
71+
// <version> is a string of form vX.Y.Z corresponding to a release of fpm
72+
// <os> is either 'linux', 'darwin', or 'win32' (as returned by process.platform)
73+
// <arch> here is always 'x86_64'
74+
//
75+
function getFPMFilename(useBootstrap,fpmVersion,platform){
76+
77+
filename = 'fpm-';
78+
79+
if (useBootstrap) {
80+
filename += 'bootstrap-';
81+
}
82+
83+
filename += fpmVersion + '-';
84+
85+
if (platform === 'linux') {
86+
87+
filename += 'linux-x86_64';
88+
89+
} else if (platform === 'darwin') {
90+
91+
filename += 'macos-x86_64';
92+
93+
} else if (platform === 'win32') {
94+
95+
filename += 'windows-x86_64.exe';
96+
97+
} else {
98+
99+
core.setFailed('Unknown platform');
100+
101+
}
102+
103+
return filename;
104+
105+
}
106+
107+
108+
// Call entry function
109+
main();

node_modules/.bin/semver

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/uuid

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/LICENSE.md

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/README.md

Lines changed: 147 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.d.ts

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)