Skip to content

Commit

Permalink
Add Github Action and CI (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
colluca authored Sep 6, 2024
1 parent 9208eda commit 0d065c1
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: ci

on: [push, pull_request]

jobs:

test-action:

name: Test Github Action

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: List prerequisites non-recursively
id: non-recursive-prerequisites
uses: ./
with:
working-directory: test
target: test
- name: Check non-recursive prerequisites
run: |
test "${{ steps.non-recursive-prerequisites.outputs.prerequisites }}" = "prereq"
echo ${{ steps.non-recursive-prerequisites.outputs.hash }}
- name: List recursive prerequisites
id: recursive-prerequisites
uses: ./
with:
working-directory: test
target: test
flags: --recursive
- name: Check recursive prerequisites
run: |
test "${{ steps.recursive-prerequisites.outputs.prerequisites }}" = "preprereq"
echo ${{ steps.recursive-prerequisites.outputs.hash }}
44 changes: 44 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "List Make Prerequisites Action"
description: "List all prerequisites of a Makefile target"
author: "Luca Colagrande"

inputs:
target:
description: "Target to list prerequisites for"
required: true
working-directory:
description: "Working directory to run Make in"
required: false
default: '.'
flags:
description: "Additional flags to pass to list-make-prerequisites.py"
required: false
default: ''

outputs:
hash:
description: "Hash of all prerequisite file contents"
value: ${{ steps.list-make-prerequisites.outputs.hash }}
prerequisites:
description: "List of all prerequisite files"
value: ${{ steps.list-make-prerequisites.outputs.prerequisites }}

runs:
using: "composite"
steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Dependencies
shell: bash
run: pip install -r requirements.txt
- name: List Make Prerequisites
id: list-make-prerequisites
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
hash=$(${GITHUB_ACTION_PATH}/list-make-prerequisites.py ${{ inputs.target }} ${{ inputs.flags }} --hash 2>/dev/null)
prerequisites=$(${GITHUB_ACTION_PATH}/list-make-prerequisites.py ${{ inputs.target }} ${{ inputs.flags }} 2>/dev/null)
echo "hash=$hash" >> $GITHUB_OUTPUT
echo "prerequisites=$prerequisites" >> $GITHUB_OUTPUT
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
anytree
5 changes: 5 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test: prereq
cp $< $@

prereq: preprereq
cp $< $@
1 change: 1 addition & 0 deletions test/preprereq
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

0 comments on commit 0d065c1

Please sign in to comment.