Skip to content

Commit

Permalink
Merge pull request #2575 from cgwalters/merge-ostree-rs
Browse files Browse the repository at this point in the history
Merge ostree-rs into this repository
  • Loading branch information
cgwalters authored May 9, 2022
2 parents 73d3c16 + 6040456 commit 891c7df
Show file tree
Hide file tree
Showing 92 changed files with 195,280 additions and 16 deletions.
55 changes: 46 additions & 9 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,68 @@
---
name: Rust

permissions:
actions: read

on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]

permissions:
contents: read
branches: [ main ]

env:
CARGO_TERM_COLOR: always
ACTIONS_LINTS_TOOLCHAIN: 1.53.0
CARGO_PROJECT_FEATURES: "v2021_3"
# Minimum supported Rust version (MSRV)
ACTION_MSRV_TOOLCHAIN: 1.54.0
# Pinned toolchain for linting
ACTION_LINTS_TOOLCHAIN: 1.56.0

jobs:
build:
runs-on: ubuntu-latest
container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
steps:
- uses: actions/checkout@v2
- name: Cache Dependencies
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
- name: Build
run: cargo build --verbose --features=${{ env['CARGO_PROJECT_FEATURES'] }}
- name: Run tests
run: cargo test --verbose --features=${{ env['CARGO_PROJECT_FEATURES'] }}
build-minimum-toolchain:
name: "Build, minimum supported toolchain (MSRV)"
runs-on: ubuntu-latest
container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Remove system Rust toolchain
run: dnf remove -y rust cargo
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env['ACTION_MSRV_TOOLCHAIN'] }}
default: true
- name: Cache Dependencies
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
- name: cargo build
run: cargo build --features=${{ env['CARGO_PROJECT_FEATURES'] }}
linting:
name: "Lints, pinned toolchain"
runs-on: ubuntu-latest
container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Remove system Rust toolchain
run: dnf remove -y rust cargo
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env['ACTIONS_LINTS_TOOLCHAIN'] }}
toolchain: ${{ env['ACTION_LINTS_TOOLCHAIN'] }}
default: true
components: rustfmt, clippy
- name: cargo fmt (check)
run: cargo fmt -- --check -l
run: cargo fmt -p ostree -- --check -l
- name: cargo clippy (warnings)
run: cargo clippy -p ostree --features=${{ env['CARGO_PROJECT_FEATURES'] }} -- -D warnings
98 changes: 93 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,94 @@
# Today, this repository only uses Rust for tests. This
# toplevel Cargo.toml helps tools like rust-analyzer understand
# that this project contains Rust code. We don't otherwise currently
# use `cargo` for any part of the core build.
[package]
authors = ["Felix Krull"]
description = "Rust bindings for libostree"
documentation = "https://docs.rs/ostree"
edition = "2018"
keywords = ["ostree", "libostree"]
license = "MIT"
name = "ostree"
readme = "README.md"
repository = "https://github.com/ostreedev/ostree-rs"
version = "0.13.6"

exclude = [
"rust-bindings/conf/**",
"rust-bindings/gir-files/**",
"rust-bindings/sys/**",
".gitlab-ci.yml",
"LICENSE.LGPL*",
]

[package.metadata.docs.rs]
features = ["dox"]

[lib]
name = "ostree"
path = "rust-bindings/src/lib.rs"

[workspace]
members = ["tests/inst"]
members = [".", "rust-bindings/sys"]

[dependencies]
bitflags = "1.2.1"
cap-std = { version = "0.24", optional = true}
io-lifetimes = { version = "0.5", optional = true}
ffi = { package = "ostree-sys", path = "rust-bindings/sys", version = "0.9.1" }
gio = "0.14"
glib = "0.14.4"
hex = "0.4.2"
libc = "0.2"
once_cell = "1.4.0"
radix64 = "0.6.2"
thiserror = "1.0.20"

[dev-dependencies]
maplit = "1.0.2"
openat = "0.1.19"
tempfile = "3"
cap-tempfile = "0.24"

[features]
cap-std-apis = ["cap-std", "io-lifetimes", "v2017_10"]
dox = ["ffi/dox"]
v2014_9 = ["ffi/v2014_9"]
v2015_7 = ["v2014_9", "ffi/v2015_7"]
v2016_3 = ["v2015_7", "ffi/v2016_3"]
v2016_4 = ["v2016_3", "ffi/v2016_4"]
v2016_5 = ["v2016_4", "ffi/v2016_5"]
v2016_6 = ["v2016_5", "ffi/v2016_6"]
v2016_7 = ["v2016_6", "ffi/v2016_7"]
v2016_8 = ["v2016_7", "ffi/v2016_8"]
v2016_14 = ["v2016_8", "ffi/v2016_14"]
v2017_1 = ["v2016_14", "ffi/v2017_1"]
v2017_2 = ["v2017_1", "ffi/v2017_2"]
v2017_3 = ["v2017_2", "ffi/v2017_3"]
v2017_4 = ["v2017_3", "ffi/v2017_4"]
v2017_6 = ["v2017_4", "ffi/v2017_6"]
v2017_7 = ["v2017_6", "ffi/v2017_7"]
v2017_8 = ["v2017_7", "ffi/v2017_8"]
v2017_9 = ["v2017_8", "ffi/v2017_9"]
v2017_10 = ["v2017_9", "ffi/v2017_10"]
v2017_11 = ["v2017_10", "ffi/v2017_11"]
v2017_12 = ["v2017_11", "ffi/v2017_12"]
v2017_13 = ["v2017_12", "ffi/v2017_13"]
v2017_15 = ["v2017_13", "ffi/v2017_15"]
v2018_2 = ["v2017_15", "ffi/v2018_2"]
v2018_3 = ["v2018_2", "ffi/v2018_3"]
v2018_5 = ["v2018_3", "ffi/v2018_5"]
v2018_6 = ["v2018_5", "ffi/v2018_6"]
v2018_7 = ["v2018_6", "ffi/v2018_7"]
v2018_9 = ["v2018_7", "ffi/v2018_9"]
v2019_2 = ["v2018_9", "ffi/v2019_2"]
v2019_3 = ["v2019_2", "ffi/v2019_3"]
v2019_4 = ["v2019_3", "ffi/v2019_4"]
v2019_6 = ["v2019_4", "ffi/v2019_6"]
v2020_1 = ["v2019_6", "ffi/v2020_1"]
v2020_2 = ["v2020_1", "ffi/v2020_2"]
v2020_4 = ["v2020_2", "ffi/v2020_4"]
v2020_7 = ["v2020_4", "ffi/v2020_7"]
v2020_8 = ["v2020_7", "ffi/v2020_8"]
v2021_1 = ["v2020_8", "ffi/v2021_1"]
v2021_2 = ["v2021_1", "ffi/v2021_2"]
v2021_3 = ["v2021_2", "ffi/v2021_3"]
v2021_4 = ["v2021_3", "ffi/v2021_4"]
v2021_5 = ["v2021_4", "ffi/v2021_5"]
2 changes: 1 addition & 1 deletion cfg.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export VC_LIST_EXCEPT_DEFAULT=^(docs/.*|git.mk|lib/.*|m4/.*|md5/.*|build-aux/.*|src/gettext\.h|.*ChangeLog|buildutil/.*)$$
export VC_LIST_EXCEPT_DEFAULT=^(rust-bindings/.*|docs/.*|git.mk|lib/.*|m4/.*|md5/.*|build-aux/.*|src/gettext\.h|.*ChangeLog|buildutil/.*)$$

local-checks-to-skip = \
sc_const_long_option \
Expand Down
28 changes: 28 additions & 0 deletions rust-bindings/.ci/generate-test-jobs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh
set -eu

get_features() {
cargo read-manifest \
| jq -jr '.features
| keys
| map(select(. != "dox"))
| map(. + " ")
| .[]'
}

cat <<EOF
include: /.ci/gitlab-ci-base.yml
EOF

features=$(get_features)

for feature in $features; do

cat <<EOF
test_feature_${feature}:
extends: .fedora-ostree-devel
script:
- cargo test --verbose --workspace --features ${feature}
EOF

done
31 changes: 31 additions & 0 deletions rust-bindings/.ci/gitlab-ci-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.sccache:
variables:
SCCACHE_URL: https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz
CARGO_TARGET_DIR: ${CI_PROJECT_DIR}/target
CARGO_HOME: ${CI_PROJECT_DIR}/cargo
SCCACHE_DIR: ${CI_PROJECT_DIR}/sccache
RUSTC_WRAPPER: sccache
cache:
paths:
- cargo/
- sccache/

# config with sccache based on Fedora Rawhide, i.e. very recent libostree
.fedora-ostree-devel:
image: registry.fedoraproject.org/fedora:rawhide
extends: .sccache
before_script:
- dnf install -y cargo rust ostree-devel
- curl -L "${SCCACHE_URL}" | tar -C /usr/bin/ -xz --wildcards --strip-components=1 '*/sccache'
# ??? This seems to not work correctly on Fedora Rawhide right now?
- ln -s /usr/bin/x86_64-redhat-linux-gnu-pkg-config /usr/bin/x86_64-redhat-linux-pkg-config

# config with sccache based on Rust image, i.e. older libostree but shorter setup and rustup access
.rust-ostree-devel:
image: rust
extends: .sccache
before_script:
- apt-get update
- apt-get install -y libostree-dev
- curl -L "${SCCACHE_URL}" | tar -C /usr/bin/ -xz --wildcards --strip-components=1 '*/sccache'

7 changes: 7 additions & 0 deletions rust-bindings/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.idea
target
cargo
sccache
**/*.rs.bk
Cargo.lock
.vagrant
21 changes: 21 additions & 0 deletions rust-bindings/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018, 2019, 2020 Felix Krull

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 891c7df

Please sign in to comment.