Skip to content

Commit

Permalink
feat: adds discover and run actions (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman authored Sep 3, 2024
1 parent d776616 commit 14bca82
Show file tree
Hide file tree
Showing 33 changed files with 26,752 additions and 15 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
workflow_call:
inputs:
forge_version:
description: |
The version of the forge CLI to install (use 'local' for testing)
required: true
type: string

jobs:
discover:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.discovery.outputs.result }}
steps:
- uses: actions/checkout@v4
- name: Setup
uses: ./forge/actions/setup
with:
forge_version: ${{ inputs.forge_version }}
- name: Discovery
id: discovery
uses: ./forge/actions/discovery
with:
filters: |
^build.*
^check.*
^test.*
check:
uses: ./.github/workflows/run.yml
needs: [discover]
with:
earthfiles: ${{ toJson(fromJson(needs.discover.outputs.result)['^check.*']) }}
forge_version: ${{ inputs.forge_version }}

build:
uses: ./.github/workflows/run.yml
needs: [discover, check]
with:
earthfiles: ${{ toJson(fromJson(needs.discover.outputs.result)['^build.*']) }}
forge_version: ${{ inputs.forge_version }}

test:
uses: ./.github/workflows/run.yml
needs: [discover, check, build]
with:
earthfiles: ${{ toJson(fromJson(needs.discover.outputs.result)['^test.*']) }}
forge_version: ${{ inputs.forge_version }}
15 changes: 15 additions & 0 deletions .github/workflows/dogfood.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Dogfood

on:
push:

permissions:
id-token: write
contents: write
packages: write

jobs:
ci:
uses: ./.github/workflows/ci.yml
with:
forge_version: local
32 changes: 32 additions & 0 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
workflow_call:
inputs:
earthfiles:
description: |
A JSON list of Earthfile paths+targets to run
required: true
type: string
forge_version:
description: |
The version of the forge CLI to install (use 'local' for testing)
required: true
type: string

jobs:
run:
name: ${{ matrix.earthfile }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
earthfile: ${{ fromJson(inputs.earthfiles) }}
steps:
- uses: actions/checkout@v4
- name: Setup CI
uses: ./forge/actions/setup
with:
forge_version: ${{ inputs.forge_version }}
- name: Run
uses: ./forge/actions/run
with:
path: ${{ matrix.earthfile }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Node
node_modules
49 changes: 49 additions & 0 deletions forge/actions/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
env:
commonjs: true
es6: true
jest: true
node: true

globals:
Atomics: readonly
SharedArrayBuffer: readonly

ignorePatterns:
- 'node_modules/'
- 'dist/'
- 'coverage/'
- '*.json'

parser: '@babel/eslint-parser'

parserOptions:
ecmaVersion: 2023
sourceType: module
requireConfigFile: false
babelOptions:
babelrc: false
configFile: false
presets:
- jest

plugins:
- jest

extends:
- eslint:recommended
- plugin:github/recommended
- plugin:jest/recommended

rules:
{
'camelcase': 'off',
'eslint-comments/no-use': 'off',
'eslint-comments/no-unused-disable': 'off',
'i18n-text/no-en': 'off',
'import/no-commonjs': 'off',
'import/no-namespace': 'off',
'no-console': 'off',
'no-unused-vars': 'off',
'prettier/prettier': 'error',
'semi': 'off'
}
1 change: 1 addition & 0 deletions forge/actions/discovery/.node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.14.0
45 changes: 45 additions & 0 deletions forge/actions/discovery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Discover Action

The discover action acts as a wrapper over the `forge scan` command from the Forge CLI.
It provides inputs that map to their respective flags.
The result from running the command is returned in the `result` output.
By default, the `--enumerate` flag is passed as this is usually the desired output format in CI.

For more information on the `scan` command, refer to the Forge CLI documentation.

## Usage

```yaml
name: Run Setup
on:
push:

permissions:
contents: read
id-token: write

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Setup
uses: input-output-hk/catalyst-forge/forge/actions/setup@master
- name: Discover
id: discovery
uses: input-output-hk/catalyst-forge/forge/actions/discover@master
with:
filters: |
^check.*
^test.*
- name: Show result
run: echo "${{ steps.discovery.outputs.result }}
```
## Inputs
| Name | Description | Required | Default |
| --------- | --------------------------------------------- | -------- | --------- |
| absolute | Output absolute paths | No | `"false"` |
| enumerate | Enumerate results into Earthfile+Target pairs | No | `"true"` |
| filters | A newline separated list of filters to apply | No | `""` |
| path | The path to search from | No | `"."` |
22 changes: 22 additions & 0 deletions forge/actions/discovery/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Discovery
description: Discovers Earthfiles
inputs:
absolute:
description: Output absolute paths
default: "false"
enumerate:
description: Enumerate results into Earthfile+Target pairs
default: "true"
filters:
description: A newline separated list of filters to apply
default: ""
path:
description: The path to search from
default: "."
outputs:
result:
description: The result of the discovery

runs:
using: node20
main: dist/index.js
Loading

0 comments on commit 14bca82

Please sign in to comment.