Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: proof of concept #1

Merged
merged 32 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1376718
feat: initial Rust-Go interop
bajtos May 22, 2023
098b3e4
docs: link to Lassie repo from README
bajtos May 22, 2023
af6274a
feat: add Lassie
bajtos May 23, 2023
f78e378
test: fetch some content over HTTP
bajtos May 23, 2023
de181b9
fixup! upgrade Lassie + fix tests
bajtos May 23, 2023
90c8afe
fixup! fix race conditions + add logging
bajtos May 23, 2023
72e8b27
fixup! code cleanup
bajtos May 23, 2023
7059840
feat: daemon configuration
bajtos May 24, 2023
c614c70
feat: build C header file describing the FFI iface
bajtos May 24, 2023
099a8df
feat: error handling
bajtos May 24, 2023
cae443b
refactor: code cleanup
bajtos May 24, 2023
407ed68
chore: setup a Linux dev container
bajtos May 25, 2023
5d5840b
chore: git-ingore Go output files
bajtos May 25, 2023
0e566a6
fix: use netgo instead of OS-level resolver
bajtos May 25, 2023
44f082c
fixup! fix formatting in devcontainer.json
bajtos May 25, 2023
a4397b3
fixup! document sysctl in devcontainer.json
bajtos May 25, 2023
1348224
chore: setup Prettier + reformat README.md
bajtos May 25, 2023
631ced5
chore: setup CI (GHA workflows)
bajtos May 25, 2023
fcd2602
feat: build on Windows
bajtos May 29, 2023
7bd066a
fixup! fix debug logging in go-lib
bajtos Jun 1, 2023
a2f563e
use Go DLL on Windows (buildmode=c-shared)
bajtos Jun 1, 2023
904dd09
copy golassie.dll to the target directory
bajtos Jun 1, 2023
2271de1
docs: Installation + Basic Use
bajtos Jun 1, 2023
67c0aba
fixup! code cleanup
bajtos Jun 1, 2023
1f222fa
docs: add links to Lassie docs
bajtos Jun 1, 2023
4ac6b7a
docs: describe Windows DLL setup
bajtos Jun 1, 2023
eefe0a3
fix Clippy warnings
bajtos Jun 1, 2023
e67950c
fixup! code cleanup
bajtos Jun 1, 2023
72f01da
final cleanup
bajtos Jun 1, 2023
ce466b3
fix formatting
bajtos Jun 1, 2023
3222841
Update README.md
bajtos Jun 1, 2023
787601c
address review comments
bajtos Jun 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[target.x86_64-pc-windows-msvc]
rustflags = [
# Link the static version of the C runtime - this seems to be a common setup for Rust CLIs.
# Zinnia binaries use the static runtime and we want to support Zinnia.
"-C", "target-feature=+crt-static",
]
44 changes: 44 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
{
"name": "Rust-Go",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/rust:1",
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "latest"
}
},

// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
"mounts": [
{
"source": "devcontainer-cargo-cache-${devcontainerId}",
"target": "/usr/local/cargo",
"type": "volume"
}
],

"runArgs": [
// It seems that Docker and/or DevContainers allow apps to listen on any port.
// Our test suite relies on port 1 being privileged (not allowed to listen on other users than root)
// and therefore fails with in the default DevContainer setup.
// Here we fix the problem by configuring ports 0-1023 as being privileged.
"--sysctl", "net.ipv4.ip_unprivileged_port_start=1024"
],

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "rustc --version && go version"

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
13 changes: 13 additions & 0 deletions .github/workflows/cargo-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Security audit
on:
push:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cargo install cargo-audit
- run: cargo audit
124 changes: 124 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Continuous integration

on:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 # Fail cache download after 2 minutes.

jobs:
build-test:
name: ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: Setup Rust
uses: dtolnay/rust-toolchain@52e69531e6f69a396bc9d1226284493a5db969ff # v1
with:
toolchain: stable
target: ${{ matrix.target }}

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 'stable'

- uses: Swatinem/rust-cache@988c164c3d0e93c4dbab36aaf5bbeb77425b2894 # v2.4.0
with:
shared-key: ${{ matrix.target }}
# Always save the build artifacts to the cache to speed up builds of additional
# commits added to an already-opened pull request.
# save-if: ${{ github.ref == 'refs/heads/main' }}


- name: Build the library
run: cargo build --lib --all-features --target=${{ matrix.target }}

- name: Run all tests
run: cargo test --all-features --target=${{ matrix.target }}

lint:
name: Run Rust linters
runs-on: ubuntu-latest
needs: build-test
steps:
- uses: actions/checkout@v3

- uses: dtolnay/rust-toolchain@52e69531e6f69a396bc9d1226284493a5db969ff # v1
with:
toolchain: stable
components: clippy,rustfmt

- uses: Swatinem/rust-cache@988c164c3d0e93c4dbab36aaf5bbeb77425b2894 # v2.4.0
with:
shared-key: "x86_64-unknown-linux-gnu"
save-if: false

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

- name: Run cargo clippy
run: cargo clippy # cargo alias to allow reuse of config locally

- name: Check rustdoc links
run: RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links --deny warnings" cargo doc --verbose --workspace --no-deps --all-features --document-private-items

prettier-check:
name: Check Markdown formatting (Prettier)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actionsx/prettier@e90ec5455552f0f640781bdd5f5d2415acb52f1a # latest
with:
# prettier CLI arguments.
args: --check .

validate_pr_title:
name: Validate PR title
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: amannn/action-semantic-pull-request@c3cd5d1ea3580753008872425915e343e351ab54 # v5.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed (newline delimited).
types: |
feat
fix
chore
docs
deps
test
ci
refactor
requireScope: false

- name: Check PR title length
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
title_length=${#TITLE}
if [ $title_length -gt 72 ]
then
echo "PR title is too long (greater than 72 characters)"
exit 1
fi
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

# Generated by Cargo
# will have compiled files and executables
debug/
target/
/target

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down Expand Up @@ -44,3 +43,5 @@ go.work
########
# Project-specific
########

go-lib/_obj
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The goal of the configuration below is to configure Prettier to lint Markdown and JavaScript files.
**/*.*
!**/*.md
!**/*.js

# Let's keep LICENSE.md in the same formatting as we use in other PL repositories
LICENSE.md
2 changes: 2 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
proseWrap: always
trailingComma: all