Skip to content

Commit b3e8f45

Browse files
ivanitskiydekobon
andcommitted
!misc: project refactor and new module structure
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 <m.yacobucci@f5.com> Elijah Zupancic <e.zupancic@f5.com>
1 parent d2c0b3a commit b3e8f45

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+5378
-1817
lines changed

.cargo/audit.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# audit config file
2+
#
3+
# It may be located in the user home (`~/.cargo/audit.toml`) or in the project
4+
# root (`.cargo/audit.toml`).
5+
#
6+
# All of the options which can be passed via CLI arguments can also be
7+
# permanently specified in this file.
8+
# It may be located in the user home (`~/.cargo/audit.toml`) or in the project
9+
# root (`.cargo/audit.toml`).
10+
11+
[advisories]
12+
ignore = ["RUSTSEC-2020-0071"]
13+
14+
# # Advisory Database Configuration
15+
# [database]
16+
# path = "~/.cargo/advisory-db" # Path where advisory git repo will be cloned
17+
# url = "https://github.com/RustSec/advisory-db.git" # URL to git repo
18+
# fetch = true # Perform a `git fetch` before auditing (default: true)
19+
# stale = false # Allow stale advisory DB (i.e. no commits for 90 days, default: false)
20+
21+
# # Output Configuration
22+
# [output]
23+
# deny = ["unmaintained"] # exit on error if unmaintained dependencies are found
24+
# format = "terminal" # "terminal" (human readable report) or "json"
25+
# quiet = false # Only print information on error
26+
# show_tree = true # Show inverse dependency trees along with advisories (default: true)
27+
28+
# # Target Configuration
29+
# [target]
30+
# arch = "x86_64" # Ignore advisories for CPU architectures other than this one
31+
# os = "linux" # Ignore advisories for operating systems other than this one
32+
33+
# [yanked]
34+
# enabled = true # Warn for yanked crates in Cargo.lock (default: true)
35+
# update_index = true # Auto-update the crates.io index (default: true)

.cargo/config.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# https://stackoverflow.com/questions/28124221/error-linking-with-cc-failed-exit-code-1
3+
#
4+
[target.x86_64-apple-darwin]
5+
rustflags = [
6+
"-C", "link-arg=-undefined",
7+
"-C", "link-arg=dynamic_lookup",
8+
]

.dockerignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
**/.idea
2+
.cargo
3+
.dockerignore
4+
.fossa.yml
5+
.git
6+
.github
7+
CHANGELOG.md
8+
CODE_OF_CONDUCT.md
9+
CONTRIBUTING.md
10+
Containerfile.debian
11+
Dockerfile
12+
GNUmakefile
13+
LICENSE.txt
14+
README.md
15+
SECURITY.md
16+
build
17+
18+
.vscode/**
19+
20+
**/target
21+
target
22+
23+
.cache/
24+
.nginx/

.fossa.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 3
2+
3+
project:
4+
id: github.com/nginxinc/ngx-rust
5+
name: ngx-rust
6+
url: github.com/nginxinc/ngx-rust
7+
8+
paths:
9+
exclude:
10+
- ./cache
11+
- ./nginx

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
**Describe the bug**
8+
A clear and concise description of what the bug is.
9+
10+
**To Reproduce**
11+
Steps to reproduce the behavior:
12+
1. See my project that depends on this project
13+
2. View logs on '....'
14+
3. Run this test I created
15+
4. See error
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Your environment**
21+
* Version of the repo - a specific commit or tag
22+
* Version of ngx-rust
23+
* Version of Rust
24+
* Version of NGINX (and all dependencies if modified)
25+
* OS and distribution
26+
* Details about containerization, virtualization, or physical environment
27+
28+
**Additional context**
29+
Add any other context about the problem here. Any log files you want to share.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
5+
---
6+
7+
**Is your feature request related to a problem? Please describe.**
8+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
9+
10+
**Describe the solution you'd like**
11+
A clear and concise description of what you want to happen.
12+
13+
**Describe alternatives you've considered**
14+
A clear and concise description of any alternative solutions or features you've considered.
15+
16+
**Additional context**
17+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### Proposed changes
2+
Describe the use case and detail of the change. If this PR addresses an issue
3+
on GitHub, make sure to include a link to that issue here in this description
4+
(not in the title of the PR).
5+
6+
### Checklist
7+
Before creating a PR, run through this checklist and mark each as complete.
8+
9+
- [ ] I have written my commit messages in the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format.
10+
- [ ] I have read the [CONTRIBUTING](/CONTRIBUTING.md) doc
11+
- [ ] I have added tests (when possible) that prove my fix is effective or that my feature works
12+
- [ ] I have checked that all unit tests pass after adding my changes
13+
- [ ] I have updated necessary documentation
14+
- [ ] I have rebased my branch onto master
15+
- [ ] I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "cargo"
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.github/workflows/cargo-audit.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Security audit
2+
on:
3+
push:
4+
paths:
5+
- '**/Cargo.toml'
6+
- '**/Cargo.lock'
7+
jobs:
8+
security_audit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- uses: actions-rs/audit-check@v1
13+
with:
14+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yaml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Rust
2+
3+
on: [ push, pull_request ]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
8+
jobs:
9+
test-linux:
10+
name: Test (Linux)
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: checkout source
14+
uses: actions/checkout@v3
15+
- name: set up cargo cache
16+
uses: actions/cache@v3
17+
continue-on-error: false
18+
with:
19+
path: |
20+
.cache/cargo/registry/index/
21+
.cache/cargo/registry/cache/
22+
.cache/cargo/git/db/
23+
key: ${{ runner.os }}-cargo
24+
restore-keys: ${{ runner.os }}-cargo
25+
- name: set up nginx source binary cache
26+
uses: actions/cache@v3
27+
continue-on-error: false
28+
with:
29+
path: |
30+
.cache/.gnupg
31+
.cache/*.tar.gz
32+
.cache/*.tar.asc
33+
.cache/*.tar.sig
34+
key: nginx-${{ hashFiles('**/nginx-sys/build.rs') }}
35+
restore-keys: nginx-
36+
- name: run tests in container
37+
run: make container-test
38+
39+
test-macos:
40+
name: Test (MacOS)
41+
runs-on: macos-latest
42+
steps:
43+
- name: install GNU make 4
44+
run: brew install make openssl
45+
- uses: actions/checkout@v3
46+
- uses: actions-rs/toolchain@v1
47+
with:
48+
profile: minimal
49+
toolchain: stable
50+
override: true
51+
- name: set up cargo cache
52+
uses: actions/cache@v3
53+
continue-on-error: false
54+
with:
55+
path: |
56+
~/.cargo/registry/index/
57+
~/.cargo/registry/cache/
58+
~/.cargo/git/db/
59+
key: ${{ runner.os }}-cargo
60+
restore-keys: ${{ runner.os }}-cargo
61+
- name: set up nginx source binary cache
62+
uses: actions/cache@v3
63+
continue-on-error: false
64+
with:
65+
path: |
66+
.cache/.gnupg
67+
.cache/*.tar.gz
68+
.cache/*.tar.asc
69+
.cache/*.tar.sig
70+
key: nginx-${{ hashFiles('**/nginx-sys/build.rs') }}
71+
restore-keys: nginx-
72+
- name: run tests
73+
uses: actions-rs/cargo@v1
74+
with:
75+
command: test
76+
args: --verbose
77+
78+
fmt:
79+
name: Rustfmt
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v3
83+
- uses: actions-rs/toolchain@v1
84+
with:
85+
profile: minimal
86+
toolchain: stable
87+
override: true
88+
- run: rustup component add rustfmt
89+
- uses: actions-rs/cargo@v1
90+
with:
91+
command: fmt
92+
args: --all -- --check
93+
94+
# clippy:
95+
# name: Clippy
96+
# runs-on: ubuntu-latest
97+
# steps:
98+
# - uses: actions/checkout@v3
99+
# - uses: actions-rs/toolchain@v1
100+
# with:
101+
# profile: minimal
102+
# toolchain: stable
103+
# override: true
104+
# - run: rustup component add clippy
105+
# - uses: actions-rs/cargo@v1
106+
# with:
107+
# command: clippy
108+
# args: -- -D warnings
109+
110+
# docs:
111+
# name: Docs
112+
# runs-on: ubuntu-latest
113+
# steps:
114+
# - name: Checkout repository
115+
# uses: actions/checkout@v3
116+
# - name: Install Rust
117+
# uses: actions-rs/toolchain@v1
118+
# with:
119+
# toolchain: stable
120+
# profile: minimal
121+
# override: true
122+
# - name: Check documentation
123+
# env:
124+
# RUSTDOCFLAGS: -D warnings
125+
# uses: actions-rs/cargo@v1
126+
# with:
127+
# command: doc
128+
# args: --no-deps --document-private-items

.github/workflows/fossa.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: License Scanning
2+
3+
on:
4+
- pull_request
5+
- push
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v2
14+
15+
- name: Run FOSSA scan and upload build data
16+
uses: fossa-contrib/fossa-action@v1
17+
with:
18+
fossa-api-key: ${{ secrets.FOSSA_API_KEY }}

0 commit comments

Comments
 (0)