Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
check

GitHub Action

Assert Command Line Output

v2.2

Assert Command Line Output

check

Assert Command Line Output

Github Action to assert / check a command line output 🕵️⚙️🖥

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Assert Command Line Output

uses: GuillaumeFalourd/assert-command-line-output@v2.2

Learn more about this action in GuillaumeFalourd/assert-command-line-output

Choose a version

Assert Command Line Output

Public workflows that use this action. Action test on Ubuntu Action test on MacOs Action test on Windows

title

Github Action to assert / check a command line output 🕵️⚙️🖥

This action allows to compare a command line output (success or error) with a file content located on the repository, or to check if it contains a specific expression.


📚 Usage

How does the action work?

how does the action work

Requirements

⚠️ The actions/checkout is mandatory to use this action, as it will be necessary to access the repository files, or to access the command line output file after the action execution.

Note: This action gathers the logic from the command-output-file-action and the diff-action.


♻️ Scenarios

1️⃣ Assert file content

Expecting command output to be EQUAL to assert.txt file content

steps:
  - uses: actions/checkout@v3
  - uses: GuillaumeFalourd/assert-command-line-output@v2.1
    with:
      command_line: ls -lha
      assert_file_path: path/to/assert.txt
      expected_result: PASSED

Expecting command output to be DIFFERENT than the assert.txt file content

steps:
  - uses: actions/checkout@v3
  - uses: GuillaumeFalourd/assert-command-line-output@v2.1
    with:
      command_line: ls -lha
      assert_file_path: path/to/assert.txt
      expected_result: FAILED

2️⃣ Assert specific file line

Expecting command output line 3 to be EQUAL than the assert.txt file content in line 3

steps:
  - uses: actions/checkout@v3
  - uses: GuillaumeFalourd/assert-command-line-output@v2.1
    with:
      command_line: ls -lha
      assert_file_path: path/to/assert.txt
      expected_result: PASSED
      specific_line: 3

Expecting command output line 3 to be DIFFERENT than the assert.txt file content in line 3

steps:
  - uses: actions/checkout@v3
  - uses: GuillaumeFalourd/assert-command-line-output@v2.1
    with:
      command_line: ls -lha
      assert_file_path: path/to/assert.txt
      expected_result: FAILED
      specific_line: 3

3️⃣ Assert specific expression

Expecting command output to contain specific expression

steps:
  - uses: actions/checkout@v3
  - uses: GuillaumeFalourd/assert-command-line-output@v2.1
    with:
      command_line: ls -lha
      contains: runner
      expected_result: PASSED

Expecting command output NOT to contain specific expression

steps:
  - uses: actions/checkout@v3
  - uses: GuillaumeFalourd/assert-command-line-output@v2.1
    with:
      command_line: ls -lha
      contains: error
      expected_result: FAILED

▶️ Action Inputs

Field Mandatory Observation
command_line YES Command Line to assert / check.
e.g: ls -lha
assert_file_path NO Path to assert file that will be compared to command line output.
e.g: path/to/assert.txt
specific_line NO Specific line to check from output file with assert file.
NEEDS assert_file_path configured.
e.g: 1 (integer value only)
contains NO String expression to check on the command line output.
e.g: string expression
expected_result NO Expected assert output.
e.g: PASSED (default) or FAILED

🔎 Good to know

  • At least one type of assert between contains, specific_line and assert_file_path has to be configured.

  • If more than one type of assert is set, the priority between them is:

    • 1️⃣ contains
    • 2️⃣ specific_line
    • 3️⃣ assert_file_path
  • You can access the output.txt file in the repository directory after running the action.


🤝 Contributing

Guidelines

🏅 Licensed

☞ This repository uses the Apache License 2.0