Skip to content

Commit

Permalink
Testing actions (#2)
Browse files Browse the repository at this point in the history
* testing actions
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Dec 4, 2021
1 parent f25e6dd commit 11ea98b
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/test-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test Spliced Action
on:
pull_request: []

jobs:
install-spliced:
runs-on: ubuntu-latest
name: Install Spliced
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Spliced
uses: ./action/install

generate-matrix:
runs-on: ubuntu-latest
permissions:
packages: write
name: Generate Spliced Matrix
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Spliced
run: pip install -e .
- name: Generate Matrix
uses: ./action/matrix
id: matrix
with:
yaml: ./examples/curl.yaml

- name: Show result
env:
matrix: ${{ steps.matrix.outputs.matrix }}
run: |
printf "${{ env.matrix }}\n"
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ghcr.io/buildsi/spliced-ubuntu-20.04:latest

WORKDIR /code
COPY . /code
RUN pip install -e .
ENTRYPOINT ["spliced"]
4 changes: 4 additions & 0 deletions action/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# GitHub Actions for Spliced

- [install](install): install a specific version (or branch) of spliced
- [matrix](matrix): generate a matrix of builds
21 changes: 21 additions & 0 deletions action/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Spliced Install Action'
description: "install spliced"
inputs:
branch:
description: The branch of spack to use (defaults to develop)
required: true
default: main
release:
description: A spack release to use (if defined, overrides branch)
required: false
default: ""

runs:
using: "composite"
steps:
- name: Install Spliced
env:
INPUT_BRANCH: ${{ inputs.branch }}
INPUT_RELEASE: ${{ inputs.release }}
run: ${{ github.action_path }}/scripts/install.sh
shell: bash
26 changes: 26 additions & 0 deletions action/install/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

# Show the user all relevant variables for debugging!
printf "release: ${INPUT_RELEASE}\n"
printf "branch: ${INPUT_BRANCH}\n"

python -m pip install --upgrade pip setuptools wheel

# Case 1: no branch or release, install from pip
if [ -z "${INPUT_BRANCH}" ] && [ -z "${INPUT_RELEASE}" ]; then
printf "Installing latest from pypi\n"
pip install spliced
elif [ ! -z "${INPUT_BRANCH}" ]; then
printf "Installing from branch ${INPUT_BRANCH}\n"
git clone -b "${INPUT_BRANCH}" https://github.com/buildsi/spliced /opt/spliced
cd /opt/spliced
pip install -e .
else
printf "Installing from release ${INPUT_RELEASE}\n"
wget https://github.com/buildsi/spliced/releases/download/v${INPUT_RELEASE}/spliced-${INPUT_RELEASE}.tar.gz
tar -xzvf spliced-${INPUT_RELEASE}.tar.gz
cd spliced-${INPUT_RELEASE}
pip install -e .
fi
25 changes: 25 additions & 0 deletions action/matrix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Spiced Matrix Generation"
description: "Generate a spliced matrix given an input YAML file"
inputs:
yaml:
description: path to the config YAML
required: true
container:
description: A optional container base to include in the matrix
required: false

outputs:
matrix:
description: matrix of spliced builds
value: ${{ steps.matrix.outputs.matrix }}

runs:
using: "composite"
steps:
- name: Generate matrix
id: matrix
env:
INPUT_YAML: ${{ inputs.yaml }}
INPUT_CONTAINER: ${{ inputs.container }}
run: ${{ github.action_path }}/scripts/generate.sh
shell: bash
21 changes: 21 additions & 0 deletions action/matrix/scripts/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -e

echo $PWD
ls

if [ ! -f "${INPUT_YAML}" ]; then
printf "${INPUT_YAML} does not exist\n"
exit
fi

COMMAND="spliced matrix ${INPUT_YAML}"

if [ ! -z "${INPUT_CONTAINER}" ]; then
COMMAND="${COMMAND} --container ${INPUT_CONTAINER}"
fi

printf "${COMMAND}\n"
${COMMAND}
echo $?
5 changes: 4 additions & 1 deletion spliced/client/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@ def generate_spack_matrix(args, experiment, command=None):

if args.outfile:
utils.write_json(matrix, args.outfile)
print("::set-output name=containers::%s\n" % json.dumps(matrix))
else:
print(json.dumps(matrix, indent=4))
print("::set-output name=matrix::%s\n" % json.dumps(matrix))
print('echo "matrix=%s" >> $GITHUB_ENV' % json.dumps(matrix))

0 comments on commit 11ea98b

Please sign in to comment.