Skip to content

Commit 497574b

Browse files
committed
Copy actions from hpcflow-new
1 parent 0bed550 commit 497574b

4 files changed

Lines changed: 119 additions & 0 deletions

File tree

compare/action.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Compare program output to a string
2+
description: >
3+
Compare the output of a program to a string given as a parameter.
4+
A single trailing newline will be ignored.
5+
inputs:
6+
command:
7+
description: The command to get the output of for comparison.
8+
required: true
9+
expected:
10+
description: The string that the output is expected to equal.
11+
required: true
12+
init:
13+
description: Extra initialisation code to run before the command to compare.
14+
required: false
15+
16+
runs:
17+
using: composite
18+
steps:
19+
- shell: bash
20+
if: runner.os != 'Windows'
21+
run: |
22+
eval $INIT
23+
actual=`$COMMAND`
24+
C='\033[0;33m'
25+
NC='\033[0m'
26+
echo -e "${C}actual:${NC} $actual"
27+
echo -e "${C}expected:${NC} $EXPECTED"
28+
[ "$actual" = "$EXPECTED" ]
29+
env:
30+
COMMAND: ${{ inputs.command }}
31+
EXPECTED: ${{ inputs.expected }}
32+
INIT: ${{ inputs.init }}
33+
- shell: pwsh
34+
if: runner.os == 'Windows'
35+
run: |
36+
if ($Env:INIT) {
37+
Invoke-Expression $Env:INIT
38+
}
39+
$actual = (Invoke-Expression $Env:COMMAND)
40+
$C = "$([char] 27)[0;33m"
41+
$NC = "$([char] 27)[0m"
42+
Write-Host "${C}actual:${NC} $actual"
43+
Write-Host "${C}expected:${NC} $Env:EXPECTED"
44+
if ($actual -ne $Env:EXPECTED) {
45+
exit 1
46+
}
47+
env:
48+
COMMAND: ${{ inputs.command }}
49+
EXPECTED: ${{ inputs.expected }}
50+
INIT: ${{ inputs.init }}

configure-git/action.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Configure git for robotic commits
2+
description: >
3+
Sets up git for robotic commits.
4+
Assumes that the correct token was used when checking out the repository!
5+
inputs:
6+
name:
7+
description: The user name for the robot.
8+
required: false
9+
default: hpcflow-actions
10+
email:
11+
description: The user email (possibly fake).
12+
required: false
13+
default: hpcflow-actions@users.noreply.github.com
14+
runs:
15+
using: composite
16+
steps:
17+
- shell: bash
18+
run: |
19+
git config user.name $ACT_NAME
20+
git config user.email $ACT_EMAIL
21+
env:
22+
ACT_NAME: ${{ inputs.name }}
23+
ACT_EMAIL: ${{ inputs.email }}

init-cache/action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Set up Python Virtual Environment cache
2+
description: >
3+
Sets up the caching of the virtual environment for a Python project controlled
4+
by Poetry.
5+
inputs:
6+
name:
7+
description: The short name of the task having its environment cached.
8+
required: true
9+
version:
10+
description: The version of Python this is for.
11+
required: true
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Cache Virtual Environment
16+
uses: actions/cache@v4
17+
with:
18+
path: ./.venv
19+
key: ${{ inputs.name }}.${{ runner.os }}-${{ inputs.version }}-venv.${{ hashFiles('**/poetry.lock') }}

setup-poetry/action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Set up Poetry
2+
description: >
3+
Sets up Poetry, assuming Python is already set up.
4+
inputs:
5+
version:
6+
description: The version of Poetry to install.
7+
required: true
8+
outputs:
9+
python-path:
10+
description: The path to Python in the virtual environment.
11+
value: ${{ steps.code.outputs.python }}
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- shell: bash
17+
id: code
18+
run: |
19+
python -m pip install poetry==$VERSION
20+
poetry config virtualenvs.in-project true
21+
poetry config installer.modern-installation false
22+
echo "python=${GITHUB_WORKSPACE}${SEP}.venv${SEP}${LOC}${SEP}python${SUFFIX}" >> $GITHUB_OUTPUT
23+
env:
24+
VERSION: ${{ inputs.version }}
25+
SEP: ${{ runner.os == 'Windows' && '\' || '/' }}
26+
LOC: ${{ runner.os == 'Windows' && 'Scripts' || 'bin' }}
27+
SUFFIX: ${{ runner.os == 'Windows' && '.exe' || '' }}

0 commit comments

Comments
 (0)