Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

38 validate action version exists #39

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a11e734
Add sections to contributing guide
award28 Mar 7, 2023
fcf615a
Add rust environment setup.
award28 Mar 7, 2023
90861f2
Update CONTRIBUTING.md
award28 Mar 7, 2023
629d854
Add remote-checks flag
award28 Mar 7, 2023
8d7248e
Capture `remote_checks` flag in all configs
award28 Mar 7, 2023
7b10b14
Create skeleton for `validate_remote_checks`
award28 Mar 7, 2023
d3aa4b5
First working prototype! Needs some cleanup, but getting closer
award28 Mar 8, 2023
dac8ef2
Working dyn trait
award28 Mar 8, 2023
1443dc1
Action validation is working! Time to get docker and path done
award28 Mar 8, 2023
be57be9
Path working - Docker in progress
award28 Mar 9, 2023
d2c4328
Docker images working :D
award28 Mar 9, 2023
2139d21
Working for all v2 docker protocols
award28 Mar 9, 2023
03505b1
Reset audit workflow
award28 Mar 9, 2023
41fcda5
Remove unused remote checks flag
award28 Mar 9, 2023
fe6e3bd
Remove spacing
award28 Mar 9, 2023
3d5cbfd
Clean up code
award28 Mar 10, 2023
baa6910
Cleanup iter
award28 Mar 10, 2023
5898f7c
Remote option return value
award28 Mar 10, 2023
334bf46
Merge branch 'main' into 38-validate-action-version-exists
award28 Mar 10, 2023
f3e0b82
Remove futures dep
award28 Mar 10, 2023
fb50f1a
Remove super import
award28 Mar 10, 2023
aba30d4
Add docs for validator
award28 Mar 10, 2023
1546226
Add model notes
award28 Mar 10, 2023
c1ffa2b
Typo
award28 Mar 10, 2023
3bdea4f
spelling
award28 Mar 10, 2023
08d4af7
Running tests through rust testing
award28 Mar 15, 2023
c95321a
Cleanup
award28 Mar 15, 2023
4c16bfb
Add remote-checks tests
award28 Mar 15, 2023
fcd0fb1
Create snap-snapshots feature
award28 Mar 15, 2023
476df9b
Move cfg
award28 Mar 15, 2023
ded9825
Update
award28 Mar 15, 2023
8e9d9ab
Update contributing.md
award28 Mar 17, 2023
6070859
Update authors
award28 Mar 17, 2023
53ffc60
Update CONTRIBUTING.md
award28 May 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Overview

* If you have found a discrepancy in documented and observed behaviour, that
is a bug. Feel free to [report it as an
issue](https://github.com/mpalmer/action-validator/issues), providing
Expand All @@ -8,3 +10,84 @@
request](https://github.com/mpalmer/action-validator/pulls).

* At all times, abide by the Code of Conduct (CODE_OF_CONDUCT.md).

---

# Environment Setup

## Install Rust
Firstly, you'll need make any changes to the core functionality of this project. We recommend use `rustup`, on the recommendation of the rust team. You can find the installation instructions [here](https://www.rust-lang.org/tools/install).

To confirm that rust is installed, run the `cargo` command. If you don't receive the help docs output, you may need to add rust to your shell rc file.

## Git Submodule Setup
This repository uses [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules). Specifically for the use of [schemastore](https://github.com/SchemaStore/schemastore).

To setup the git submodule after cloning this repo to your local, you'll want to run the following commands:
award28 marked this conversation as resolved.
Show resolved Hide resolved
1. `git submodule init`
2. `git submodule update`

It should look similar to the output below.

```bash
❯ git submodule init
Submodule 'src/schemastore' (https://github.com/SchemaStore/schemastore) registered for path 'src
/schemastore'
❯ git submodule update
Cloning into '/Users/someuser/action-validator/src/schemastore'...
Submodule path 'src/schemastore': checked out 'd3e6ab7727380b214acbab05570fb09a3e5d2dfc'
```

At this point, you should be all set to `cargo run`! If you run into any issues here, please [create an issue](https://github.com/mpalmer/action-validator/issues/new/choose).

# Running the Validator Locally

## `cargo run [FILE] -- [OPTIONS]`
`cargo run` will create a _debug_ executable and run the project. If this is your first time running the command, cargo will compile the development binary with `cargo build`. This will install all of the dependencies and create the debug binary `action-validator` in the `/target/debug/` directory. `cargo run` will then invoke this binary after creation.

One caveat if you're running with `cargo run`: if you want to supply the program with options, you need to use the `--` operator between `cargo run` and your provided options. This let's cargo know which flags are meant for cargo, and which are meant for the executable.

## `cargo build` && `./target/debug/action-validator [OPTIONS]`
As discussed in the prior section, `cargo build` install dependencies (if they're not cached) and build the development binary. This binary can then be invoked directly by running `./target/debug/action-validator`. This does **not** require the use of the `--` operator in between the binary and any provided options.

## Try It Yourself!

Run the command `cargo run -- --help`. You should see an output similar to the following.
```bash
❯ cargo run -- --help
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running `target/debug/action-validator --help`
A validator for GitHub Action and Workflow YAML files

Usage: action-validator [OPTIONS] [path_to_action_yaml]...

Arguments:
[path_to_action_yaml]... Input file

Options:
-v, --verbose Be more verbose
-h, --help Print help information
-V, --version Print version information
```

# Writing Tests
All tests live in the `tests` directory. Currently, this project implements snapshot testing,
but that's not to say you couldn't write unit or integration tests with the current structure.
To run the tests, simply run `cargo test` from the root directory. If you want to test a specific
feature, you can add the `-F {feature}` flag (e.g. `cargo test -F remote-checks`).

## Unit/Integration Tests
As of this writing, there are no unit or integration tests. If you are looking to write some, please
follow the directions in [this guide](https://doc.rust-lang.org/book/ch11-01-writing-tests.html).

## Snapshot Tests
A snapshot test is performed when we execute the cli and capture `stdout`, `stderr`, and/or an exit code.
When the tests is run, the results of the test must exactly match those of the previous run. For this project,
the snapshot tests are named in the format `{next_id}_{whats_being_tested}` (e.g. `011_remote_checks_failure`).

If you have made changes which will change the output of the program and cause snapshots to fail, you can run
`cargo test -F save-snapshots`. This feature causes the executed command to save the `stdout`, `stderr`, and/or
exit code to the specified testing directory.

If you are writing a net new test, you will need to create the test directory with your workflow or action file.
Once you're done, you can save the results to that directy by running `cargo test -F save-snapshots`.
Loading