Skip to content

Commit 4126aa1

Browse files
committed
Setup GitHub Actions and other GitHub-specifics.
1 parent 6ea479e commit 4126aa1

File tree

9 files changed

+311
-0
lines changed

9 files changed

+311
-0
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
6+
7+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8+
9+
## Our Standards
10+
11+
Examples of behavior that contributes to a positive environment for our community include:
12+
13+
- Demonstrating empathy and kindness toward other people
14+
- Being respectful of differing opinions, viewpoints, and experiences
15+
- Giving and gracefully accepting constructive feedback
16+
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17+
- Focusing on what is best not just for us as individuals, but for the overall community
18+
19+
Examples of unacceptable behavior include:
20+
21+
- The use of sexualized language or imagery, and sexual attention or advances of any kind
22+
- Trolling, insulting or derogatory comments, and personal or political attacks
23+
- Public or private harassment
24+
- Publishing others' private information, such as a physical or email address, without their explicit permission
25+
- Other conduct which could reasonably be considered inappropriate in a professional setting
26+
27+
## Enforcement Responsibilities
28+
29+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
32+
33+
## Scope
34+
35+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
36+
37+
## Enforcement
38+
39+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement via eMail to [email protected]. All complaints will be reviewed and investigated promptly and fairly.
40+
41+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
42+
43+
## Enforcement Guidelines
44+
45+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
46+
47+
### 1. Correction
48+
49+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
50+
51+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
52+
53+
### 2. Warning
54+
55+
**Community Impact**: A violation through a single incident or series of actions.
56+
57+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
58+
59+
### 3. Temporary Ban
60+
61+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
62+
63+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
64+
65+
### 4. Permanent Ban
66+
67+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
68+
69+
**Consequence**: A permanent ban from any sort of public interaction within the community.
70+
71+
## Attribution
72+
73+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
74+
75+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][mozilla coc].
76+
77+
For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][faq]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
78+
79+
[homepage]: https://www.contributor-covenant.org
80+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
81+
[mozilla coc]: https://github.com/mozilla/diversity
82+
[faq]: https://www.contributor-covenant.org/faq
83+
[translations]: https://www.contributor-covenant.org/translations

.github/CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Contributing
2+
3+
Whoop! Whoop! Thanks for reading this! I welcome your contribution!
4+
5+
## Non-code contributions
6+
7+
All contributions matter. You don't have to be an experienced programmer to contribute to this project. Every single issue filed, any question asked, and all improvements to the documentation is welcome!
8+
9+
## Code contributions
10+
11+
For smaller changes that do not affect the applications behavior in a breaking way, like bugfixes, refactoring, and similar things: please feel free to submit a Pull Request!
12+
13+
For larger changes that have an effect on this applications behavior and might even break existing setups, please open an issue first so we can have a chance to discuss about your plans first.

.github/SECURITY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
Only the latest version of this application is supported.
6+
7+
## Reporting a Vulnerability
8+
9+
Please send an email to [[email protected]](mailto:[email protected]) or reach out to me on Matrix to [@denschub:schub.social](https://matrix.to/#/@denschub:schub.social) to privately report a vulnerability.

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
8+
- package-ecosystem: cargo
9+
directory: /
10+
schedule:
11+
interval: weekly
12+
open-pull-requests-limit: 100

.github/rust-env/action.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Rust env setup
2+
description: Installs the latest Rust toolchain, and sets up caching
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Install latest stable Rust toolchain
8+
shell: bash
9+
run: rustup update stable
10+
- name: Set up short-term caching
11+
uses: actions/cache@v4
12+
with:
13+
path: |
14+
~/.cargo/registry
15+
~/.cargo/git
16+
target
17+
key: ${{ runner.os }}-build-cargo-${{ github.sha }}

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- release
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-20.04
15+
env:
16+
AWS_LC_SYS_CMAKE_BUILDER: true
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Update system
20+
run: sudo apt-get update && sudo apt-get install -y cmake
21+
- name: Update Rust
22+
run: rustup update stable
23+
- name: Build release artifacts
24+
run: cargo install --locked --path . --root ./out
25+
# https://github.com/actions/upload-artifact/issues/38 is still not fixed.
26+
- name: Package the binary
27+
run: |
28+
cd out/bin/
29+
zip nginx-syslog-postgres-bridge.zip nginx-syslog-postgres-bridge
30+
- name: Get the built version number
31+
id: version_number
32+
run: echo "version=$(out/bin/nginx-syslog-postgres-bridge --version | awk -F ' ' '{print $2}')" >> $GITHUB_OUTPUT
33+
- name: Upload release artifacts
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: nginx-syslog-postgres-bridge-${{ steps.version_number.outputs.version }}-linux-amd64
37+
path: out/bin/nginx-syslog-postgres-bridge.zip
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: docker-develop
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-20.04
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Login to DockerHub
17+
uses: docker/login-action@v3
18+
with:
19+
username: ${{ vars.DOCKERHUB_USER }}
20+
password: ${{ secrets.DOCKERHUB_TOKEN }}
21+
- name: Login to GitHub Container Registry
22+
uses: docker/login-action@v3
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Build and push
28+
uses: docker/build-push-action@v5
29+
with:
30+
context: .
31+
push: true
32+
tags: |
33+
ghcr.io/${{ github.repository }}:develop,
34+
${{ github.repository }}:develop
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: docker-release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-20.04
11+
permissions:
12+
contents: read
13+
packages: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Split tag name into semver-compatible subsections
17+
id: version_numbers
18+
run: |
19+
echo "patch=$(echo $GITHUB_REF | sed 's=refs/tags/v==g')" >> $GITHUB_OUTPUT
20+
echo "minor=$(echo $GITHUB_REF | sed 's=refs/tags/v==g' | cut -d "." -f 1,2)" >> $GITHUB_OUTPUT
21+
echo "major=$(echo $GITHUB_REF | sed 's=refs/tags/v==g' | cut -d "." -f 1)" >> $GITHUB_OUTPUT
22+
- name: Login to DockerHub
23+
uses: docker/login-action@v3
24+
with:
25+
username: ${{ vars.DOCKERHUB_USER }}
26+
password: ${{ secrets.DOCKERHUB_TOKEN }}
27+
- name: Login to GitHub Container Registry
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Build and push
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
push: true
38+
tags: |
39+
ghcr.io/${{ github.repository }}:latest,
40+
ghcr.io/${{ github.repository }}:${{ steps.version_numbers.outputs.patch }},
41+
ghcr.io/${{ github.repository }}:${{ steps.version_numbers.outputs.minor }},
42+
ghcr.io/${{ github.repository }}:${{ steps.version_numbers.outputs.major }},
43+
${{ github.repository }}:latest,
44+
${{ github.repository }}:${{ steps.version_numbers.outputs.patch }},
45+
${{ github.repository }}:${{ steps.version_numbers.outputs.minor }},
46+
${{ github.repository }}:${{ steps.version_numbers.outputs.major }}

.github/workflows/test.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
- release
8+
pull_request:
9+
types:
10+
- opened
11+
- synchronize
12+
- reopened
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-20.04
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: ./.github/rust-env
23+
- run: cargo build --all-targets --all-features
24+
25+
test:
26+
needs: build
27+
runs-on: ubuntu-20.04
28+
env:
29+
DATABASE_URL: postgres://postgres@localhost:5432/nginx_logs
30+
services:
31+
postgres:
32+
image: timescale/timescaledb-ha:pg16
33+
env:
34+
POSTGRES_HOST_AUTH_METHOD: trust
35+
ports:
36+
- 5432:5432
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: ./.github/rust-env
40+
- run: |
41+
cargo install sqlx-cli
42+
cargo sqlx database setup
43+
- run: cargo sqlx prepare --check -- --lib
44+
- run: cargo test --all-targets --all-features -- --color=always
45+
46+
clippy:
47+
needs: build
48+
runs-on: ubuntu-20.04
49+
steps:
50+
- uses: actions/checkout@v4
51+
- uses: ./.github/rust-env
52+
- run: cargo clippy --all-targets --all-features -- -D warnings
53+
54+
rustfmt:
55+
needs: build
56+
runs-on: ubuntu-20.04
57+
steps:
58+
- uses: actions/checkout@v4
59+
- uses: ./.github/rust-env
60+
- run: cargo fmt --all -- --check

0 commit comments

Comments
 (0)