Skip to content

Commit

Permalink
The second revision (#2)
Browse files Browse the repository at this point in the history
- Simplified the `Makefile` and removed the `install-hooks` target.
- Added dual licensing support (APACHE V2 and MIT) to the project.
- Updated the `README.md` and improved badge styling.
- Updated the `.editorconfig` file and added support for formatting YAML files.
- Updated the `CONTRIBUTIONS.md` and added licensing notice for pull requests.
- Updated the GitHub Actions workflows and removed unnecessary comments.
  • Loading branch information
habedi authored Feb 2, 2025
1 parent f65b9f5 commit 93649aa
Show file tree
Hide file tree
Showing 19 changed files with 234 additions and 250 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ trim_trailing_whitespace = false # Don't remove trailing whitespace in Markdown
[*.sh]
indent_size = 2
# YAML files
[*.{yaml,yml}]
indent_size = 2
10 changes: 2 additions & 8 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,31 @@ jobs:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4

# Set up Rust
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

# Install dependencies and run the tests
- name: Install Dependencies and Run Tests
run: |
sudo apt-get update
sudo apt-get install -y make
make test
continue-on-error: false

# Build the application
- name: Build for Linux
run: |
make build
continue-on-error: false

# Debug: List Build Directory
- name: List Build Directory
- name: List Build Directory (for Debugging)
run: ls -R target

# Upload Build Artifact
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: template-rust-project-linux-amd64
path: 'target/release/template-rust-project'
path: 'target/release/template-rust-project'
10 changes: 2 additions & 8 deletions .github/workflows/build_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,30 @@ jobs:
runs-on: macos-latest

steps:
# Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4

# Set up Rust
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

# Install dependencies and run the tests
- name: Install Dependencies
run: |
brew install make
make test
continue-on-error: false

# Build the application
- name: Build for MacOS
run: |
make build
continue-on-error: false

# Debug: List Build Directory
- name: List Build Directory
- name: List Build Directory (for Debugging)
run: ls -R target

# Upload Build Artifact
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: template-rust-project-macos-amd64
path: 'target/release/template-rust-project'
path: 'target/release/template-rust-project'
10 changes: 2 additions & 8 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,30 @@ jobs:
runs-on: windows-latest

steps:
# Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4

# Set up Rust
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable

# Install dependencies and run the tests
- name: Install Dependencies
run: |
choco install make -y
make test
continue-on-error: false

# Build the application
- name: Build for Windows
run: |
make build
continue-on-error: false

# Debug: List Build Directory
- name: List Build Directory
- name: List Build Directory (for Debugging)
run: ls -R target

# Upload Build Artifact
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: template-rust-project-windows-amd64
path: 'target/release/template-rust-project.exe'
path: 'target/release/template-rust-project.exe'
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Rust (Stable)
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@ on:
- 'v*' # Trigger on version tags

jobs:

# Run tests before publishing and only publish if tests pass
call_tests:
uses: ./.github/workflows/tests.yml

publish:
runs-on: ubuntu-latest

# Try to publish only if the tests pass
needs: call_tests
if: success()

steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -18,21 +28,11 @@ jobs:
with:
toolchain: stable

- name: Verify Git State
run: |
git status
git diff --exit-code || (echo "Uncommitted changes detected!" && exit 1)
- name: Run Tests
run: |
sudo apt-get update
sudo apt-get install -y make
make test
continue-on-error: false

- name: Publish to Crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
sudo apt-get update
sudo apt-get install -y make
cargo publish --token $CARGO_REGISTRY_TOKEN
continue-on-error: false
8 changes: 3 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: Tests

on:
workflow_dispatch: { } # Allow manual execution
push:
tags:
- 'v*' # Trigger on version tags
workflow_call: # Make this workflow callable from other workflows

jobs:
build:
Expand All @@ -13,7 +11,7 @@ jobs:
strategy:
matrix:
# Define the Rust versions to test against
rust-version: [ "1.84.0", "beta", "stable" ]
rust-version: [ "1.83.0", "1.84.0", "beta", "stable" ]

steps:
- name: Checkout Repository
Expand All @@ -33,7 +31,7 @@ jobs:
- name: Run Tests and Generate Coverage Report
run: make coverage # Generates a coverage report

- name: Upload coverage reports to Codecov
- name: Upload Coverage Reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ would like to work on or if it has already been resolved.
- Write a clear description of the changes you made and the reasons behind them.

> [!IMPORTANT]
> It's assumed that by submitting a pull request, you agree to license your code under the project's license(s).
> Unless you explicitly state otherwise, any contribution you intentionally submit for inclusion in the work, as defined
> in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.
## Development Workflow

Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "template-rust-project"
version = "0.2.0"
version = "0.2.3"
description = "A template for Rust projects"
repository = "https://github.com/habedi/template-rust-project"
license = "MIT"
license = "MIT OR Apache-2.0"
readme = "README.md"
keywords = ["rust", "project-template"]
keywords = ["project-template", "rust", "library", "application"]
authors = ["Hassan Abedi <[email protected]>"]
homepage = "https://github.com/habedi/template-rust-project"
documentation = "https://docs.rs/template-rust-project"
Expand Down
9 changes: 1 addition & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,4 @@ lint: format ## Run linters on Rust files
.PHONY: publish
publish: ## Publish the package to crates.io (requires CARGO_REGISTRY_TOKEN to be set)
@echo "Publishing the package to Cargo registry..."
cargo publish --token $(CARGO_REGISTRY_TOKEN)

.PHONY: install-hooks
install-hooks: ## Install pre-commit hooks (run if `make publish` fails due to `uncommitted changes`)
@echo "Installing pre-commit hooks..."
@mkdir -p .git/hooks
@echo '#!/bin/sh\nmake format\n' > .git/hooks/pre-commit
@chmod +x .git/hooks/pre-commit
cargo publish --token $(CARGO_REGISTRY_TOKEN)
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ I share it here in case it might be useful to others.
- Pre-configured GitHub Actions for running tests and making releases for different platforms
- Makefile for managing common tasks such as formatting, testing, linting, and building
- Example configuration files for common tools like `rustfmt`, `clippy`, and `editorconfig`
- GitHub badges for tests, builds, code quality and coverage, documentation, etc.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to make a contribution.

## License

This project is licensed either under the [MIT License](LICENSE-MIT) or the [Apache License 2.0](LICENSE-APACHE), at
your option.
This project is licensed under either of these:

* MIT License ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
3 changes: 3 additions & 0 deletions assets/logos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Sources

- [rustacean.net](https://rustacean.net/)
Loading

0 comments on commit 93649aa

Please sign in to comment.