Skip to content

Commit

Permalink
Re-organize and normalize CLI tests
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Cornelissen <[email protected]>
  • Loading branch information
ericcornelissen committed Dec 16, 2023
1 parent cabb12c commit b7b888d
Show file tree
Hide file tree
Showing 16 changed files with 398 additions and 323 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ func runOnStdin() (map[string]map[string][]violation, bool) {

violations := make(map[string][]violation)
if workflowViolations, err := tryWorkflow(data); err != nil {
fmt.Println("Could not parse input, is it YAML?")
return nil, false
} else if len(workflowViolations) != 0 {
violations["stdin"] = workflowViolations
} else if manifestViolations, err := tryManifest(data); err != nil {
return nil, false
} else {
manifestViolations, _ := tryManifest(data)
violations["stdin"] = manifestViolations
}

Expand Down
53 changes: 0 additions & 53 deletions test/args-manifest.txtar

This file was deleted.

33 changes: 0 additions & 33 deletions test/args-multiple.txtar

This file was deleted.

22 changes: 0 additions & 22 deletions test/args-workflow.txtar

This file was deleted.

153 changes: 153 additions & 0 deletions test/args.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Empty project
mkdir empty

exec ades 'empty'
! stdout .
! stderr .

# Safe project
exec ades 'safe'
! stdout .
! stderr .

# Unsafe manifest (.yml)
! exec ades 'manifests/action.yml'
stdout 'manifests/action.yml'
! stderr .

# Unsafe manifest (.yaml)
! exec ades 'manifests/action.yaml'
stdout 'manifests/action.yaml'
! stderr .

# Unsafe workflow (.yml)
! exec ades 'workflows/.github/workflows/unsafe.yml'
stdout 'workflows/.github/workflows/unsafe.yml'
! stderr .

# Unsafe workflow (.yaml)
! exec ades 'workflows/.github/workflows/unsafe.yaml'
stdout 'workflows/.github/workflows/unsafe.yaml'
! stderr .

# Unsafe project
! exec ades 'workflows'
stdout '.github/workflows/unsafe.yml'
stdout '.github/workflows/unsafe.yaml'
! stderr .

# Multiple targets
! exec ades 'safe' 'workflows' 'manifests/action.yml'
stdout '[safe]'
stdout '[workflows]'
stdout '[manifest/action.yml]'
! stderr .


-- manifests/action.yml --
name: Example unsafe action
description: Sample action for testing _ades_

inputs:
name:
description: The name of the person to greet.
required: false
default: GeT_RiGhT

runs:
using: composite
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Safe run
run: echo 'Hello .yml'
- name: Unsafe run
run: echo 'Hello ${{ inputs.name }}'
-- manifests/action.yaml --
name: Example unsafe action
description: Sample action for testing _ades_

inputs:
name:
description: The name of the person to greet.
required: false
default: GeT_RiGhT

runs:
using: composite
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Safe run
run: echo 'Hello .yml'
- name: Unsafe run
run: echo 'Hello ${{ inputs.name }}'
-- safe/.github/workflows/safe.yml --
name: Example safe workflow
on: [push]

jobs:
example:
name: Example safe job
runs-on: ubuntu-latest
steps:
- name: Safe run
run: echo 'Hello .yml!'
-- safe/.github/workflows/safe.yaml --
name: Example safe workflow
on: [push]

jobs:
example:
name: Example safe job
runs-on: ubuntu-latest
steps:
- name: Safe run
run: echo 'Hello .yaml!'
-- safe/action.yml --
name: Example safe action
description: Sample action for testing _ades_

inputs:
name:
description: The name of the person to greet.
required: false
default: GeT_RiGhT

runs:
using: composite
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Safe run
run: echo 'Hello .yml'
-- workflows/.github/workflows/unsafe.yml --
name: Example unsafe workflow
on: [push]

jobs:
example:
name: Example unsafe job
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Safe run
run: echo 'Hello .yml'
- name: Unsafe run
run: echo 'Hello ${{ inputs.name }}'
-- workflows/.github/workflows/unsafe.yaml --
name: Example unsafe workflow
on: [push]

jobs:
example:
name: Example unsafe job
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Safe run
run: echo 'Hello .yaml'
- name: Unsafe run
run: echo 'Hello ${{ inputs.name }}'
31 changes: 0 additions & 31 deletions test/cwd-clean.txtar

This file was deleted.

53 changes: 0 additions & 53 deletions test/cwd-manifest.txtar

This file was deleted.

Loading

0 comments on commit b7b888d

Please sign in to comment.