Skip to content

Commit

Permalink
!misc: project refactor and new module structure
Browse files Browse the repository at this point in the history
New crates:
 - nginx-sys - is a separate crate for nginx bindings
 - ngx - crate allows to use a higher-level abstractions to build modules in rust
- examples - a number of examples how to develop nginx dynamic modules with Rust

ngx v0.3.0-beta now has more rust idiomatic code and allows to build modules completely in rust without any C code

Co-authored-by: Matthew Yacobucci <[email protected]> Elijah Zupancic <[email protected]>
  • Loading branch information
ivanitskiy and dekobon committed Apr 18, 2023
1 parent d2c0b3a commit b3e8f45
Show file tree
Hide file tree
Showing 72 changed files with 5,378 additions and 1,817 deletions.
35 changes: 35 additions & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# audit config file
#
# It may be located in the user home (`~/.cargo/audit.toml`) or in the project
# root (`.cargo/audit.toml`).
#
# All of the options which can be passed via CLI arguments can also be
# permanently specified in this file.
# It may be located in the user home (`~/.cargo/audit.toml`) or in the project
# root (`.cargo/audit.toml`).

[advisories]
ignore = ["RUSTSEC-2020-0071"]

# # Advisory Database Configuration
# [database]
# path = "~/.cargo/advisory-db" # Path where advisory git repo will be cloned
# url = "https://github.com/RustSec/advisory-db.git" # URL to git repo
# fetch = true # Perform a `git fetch` before auditing (default: true)
# stale = false # Allow stale advisory DB (i.e. no commits for 90 days, default: false)

# # Output Configuration
# [output]
# deny = ["unmaintained"] # exit on error if unmaintained dependencies are found
# format = "terminal" # "terminal" (human readable report) or "json"
# quiet = false # Only print information on error
# show_tree = true # Show inverse dependency trees along with advisories (default: true)

# # Target Configuration
# [target]
# arch = "x86_64" # Ignore advisories for CPU architectures other than this one
# os = "linux" # Ignore advisories for operating systems other than this one

# [yanked]
# enabled = true # Warn for yanked crates in Cargo.lock (default: true)
# update_index = true # Auto-update the crates.io index (default: true)
8 changes: 8 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# https://stackoverflow.com/questions/28124221/error-linking-with-cc-failed-exit-code-1
#
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
24 changes: 24 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**/.idea
.cargo
.dockerignore
.fossa.yml
.git
.github
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Containerfile.debian
Dockerfile
GNUmakefile
LICENSE.txt
README.md
SECURITY.md
build

.vscode/**

**/target
target

.cache/
.nginx/
11 changes: 11 additions & 0 deletions .fossa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 3

project:
id: github.com/nginxinc/ngx-rust
name: ngx-rust
url: github.com/nginxinc/ngx-rust

paths:
exclude:
- ./cache
- ./nginx
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. See my project that depends on this project
2. View logs on '....'
3. Run this test I created
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Your environment**
* Version of the repo - a specific commit or tag
* Version of ngx-rust
* Version of Rust
* Version of NGINX (and all dependencies if modified)
* OS and distribution
* Details about containerization, virtualization, or physical environment

**Additional context**
Add any other context about the problem here. Any log files you want to share.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### Proposed changes
Describe the use case and detail of the change. If this PR addresses an issue
on GitHub, make sure to include a link to that issue here in this description
(not in the title of the PR).

### Checklist
Before creating a PR, run through this checklist and mark each as complete.

- [ ] I have written my commit messages in the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format.
- [ ] I have read the [CONTRIBUTING](/CONTRIBUTING.md) doc
- [ ] I have added tests (when possible) that prove my fix is effective or that my feature works
- [ ] I have checked that all unit tests pass after adding my changes
- [ ] I have updated necessary documentation
- [ ] I have rebased my branch onto master
- [ ] I will ensure my PR is targeting the main branch and pulling from my branch from my own fork
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "cargo"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
14 changes: 14 additions & 0 deletions .github/workflows/cargo-audit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Security audit
on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
128 changes: 128 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Rust

on: [ push, pull_request ]

env:
CARGO_TERM_COLOR: always

jobs:
test-linux:
name: Test (Linux)
runs-on: ubuntu-latest
steps:
- name: checkout source
uses: actions/checkout@v3
- name: set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
.cache/cargo/registry/index/
.cache/cargo/registry/cache/
.cache/cargo/git/db/
key: ${{ runner.os }}-cargo
restore-keys: ${{ runner.os }}-cargo
- name: set up nginx source binary cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
.cache/.gnupg
.cache/*.tar.gz
.cache/*.tar.asc
.cache/*.tar.sig
key: nginx-${{ hashFiles('**/nginx-sys/build.rs') }}
restore-keys: nginx-
- name: run tests in container
run: make container-test

test-macos:
name: Test (MacOS)
runs-on: macos-latest
steps:
- name: install GNU make 4
run: brew install make openssl
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo
restore-keys: ${{ runner.os }}-cargo
- name: set up nginx source binary cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
.cache/.gnupg
.cache/*.tar.gz
.cache/*.tar.asc
.cache/*.tar.sig
key: nginx-${{ hashFiles('**/nginx-sys/build.rs') }}
restore-keys: nginx-
- name: run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --verbose

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

# clippy:
# name: Clippy
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
# override: true
# - run: rustup component add clippy
# - uses: actions-rs/cargo@v1
# with:
# command: clippy
# args: -- -D warnings

# docs:
# name: Docs
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# profile: minimal
# override: true
# - name: Check documentation
# env:
# RUSTDOCFLAGS: -D warnings
# uses: actions-rs/cargo@v1
# with:
# command: doc
# args: --no-deps --document-private-items
18 changes: 18 additions & 0 deletions .github/workflows/fossa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: License Scanning

on:
- pull_request
- push

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Run FOSSA scan and upload build data
uses: fossa-contrib/fossa-action@v1
with:
fossa-api-key: ${{ secrets.FOSSA_API_KEY }}
Loading

0 comments on commit b3e8f45

Please sign in to comment.