Skip to content

Commit

Permalink
refactor: refactor cli and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelopsio committed Dec 1, 2024
1 parent eb6676f commit 73d04d6
Show file tree
Hide file tree
Showing 16 changed files with 825 additions and 74 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt

- name: Rust Cache
uses: Swatinem/rust-cache@v2

- name: Check formatting
run: cargo fmt --all -- --check

- name: Clippy
run: cargo clippy -- -D warnings

- name: Run tests
run: cargo test --all-features

conventional-commits:
name: Conventional Commits
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check conventional commits
uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release:
name: Release
runs-on: ubuntu-latest
needs: [test]
if: github.ref == 'refs/heads/main'

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
with:
extra_plugins: |
@semantic-release/git
@semantic-release/changelog
@semantic-release/exec
53 changes: 0 additions & 53 deletions .github/workflows/rust-general.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/rust-security.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
[
"@semantic-release/exec",
{
"prepareCmd": "./scripts/bump-version.sh ${nextRelease.version}"
}
],
[
"@semantic-release/git",
{
"assets": ["Cargo.toml", "Cargo.lock", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
}
69 changes: 69 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Contributing to TBD IAC

## Commit Convention

We use [Conventional Commits](https://www.conventionalcommits.org/) for commit messages. This allows us to automatically generate changelogs and determine semantic version bumps.

### Format

```
<type>(<scope>): <description>
[optional body]
[optional footer(s)]
```

### Types

- `feat`: A new feature (correlates with MINOR in SemVer)
- `fix`: A bug fix (correlates with PATCH in SemVer)
- `docs`: Documentation only changes
- `style`: Changes that do not affect the meaning of the code
- `refactor`: A code change that neither fixes a bug nor adds a feature
- `perf`: A code change that improves performance
- `test`: Adding missing tests or correcting existing tests
- `chore`: Changes to the build process or auxiliary tools
- `ci`: Changes to CI configuration files and scripts

### Breaking Changes

Add `BREAKING CHANGE:` in the commit footer to trigger a major version bump:

```
feat: allow provided config object to extend other configs
BREAKING CHANGE: `extends` key in config file is now used for extending other config files
```

### Examples

```
feat(cli): add provider install command
fix(state): handle concurrent state updates
docs(readme): update installation instructions
test(init): add test for project initialization
```

## Development Workflow

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Write/update tests
5. Run tests locally: `cargo test`
6. Push changes
7. Create Pull Request

## Running Tests

```bash
# Run all tests
cargo test

# Run specific test
cargo test test_init_creates_project_structure

# Run with logging
RUST_LOG=debug cargo test
```
38 changes: 37 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,43 @@
name = "tbd-iac"
version = "0.1.0"
edition = "2021"
authors = ["Stephen Morgan <[email protected]>"]
description = "Infrastructure as Code tool"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[bin]]
name = "tbd"
path = "src/main.rs"
[lib]
name = "tbd_iac"
path = "src/lib.rs"

[dependencies]
# Command line argument parsing
clap = { version = "4.4", features = ["derive"] }

# Async runtime and traits
tokio = { version = "1.35", features = ["full"] }
async-trait = "0.1"

# Logging and tracing
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

# Error handling
anyhow = "1.0"
thiserror = "1.0"

# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.8"

# File system operations
fs_extra = "1.3"

[dev-dependencies]

tempfile = "3.8"
assert_fs = "1.0"
predicates = "3.0"
Loading

0 comments on commit 73d04d6

Please sign in to comment.