Skip to content

Commit

Permalink
Merge remote-tracking branch 'ostree-rs/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
cgwalters committed Mar 31, 2022
2 parents fdfb353 + 3ff0e0d commit bbc3242
Show file tree
Hide file tree
Showing 91 changed files with 193,198 additions and 0 deletions.
28 changes: 28 additions & 0 deletions rust/.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/.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'

68 changes: 68 additions & 0 deletions rust/.github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Rust

permissions:
actions: read

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

env:
CARGO_TERM_COLOR: always
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['ACTION_LINTS_TOOLCHAIN'] }}
default: true
components: rustfmt, clippy
- name: cargo fmt (check)
run: cargo fmt -p ostree -- --check -l
- name: cargo clippy (warnings)
run: cargo clippy -p ostree --features=${{ env['CARGO_PROJECT_FEATURES'] }} -- -D warnings
7 changes: 7 additions & 0 deletions rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.idea
target
cargo
sccache
**/*.rs.bk
Cargo.lock
.vagrant
90 changes: 90 additions & 0 deletions rust/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
include: /.ci/gitlab-ci-base.yml

stages:
- test
- publish

# generate feature test jobs
generate-test-jobs:
stage: .pre
image: rust
script:
- mkdir -p target
- apt-get update && apt-get install -y jq
- .ci/generate-test-jobs.sh > target/test-jobs.yaml
artifacts:
paths:
- target/test-jobs.yaml

# test
check:
stage: test
extends: .rust-ostree-devel
script:
- rustup component add clippy rustfmt
# fmt
- cargo fmt --package ostree -- --check
# check generated code
- rm -rf src/auto/
- make gir
- git checkout -- sys/src/auto/versions.txt src/auto/versions.txt
- git diff -R --exit-code
# clippy
- cargo clippy --workspace --all-features

test_default-features:
extends: .fedora-ostree-devel
script:
- cargo test --verbose --workspace

test_all_features:
stage: test
trigger:
include:
- artifact: target/test-jobs.yaml
job: generate-test-jobs
strategy: depend

build_aarch64:
stage: test
extends: .rust-ostree-devel
script:
- rustup target add aarch64-unknown-linux-gnu
- PKG_CONFIG_ALLOW_CROSS=1 cargo build --verbose --workspace --all-features --target aarch64-unknown-linux-gnu

# docs
pages:
stage: publish
extends: .rust-ostree-devel
image: rustlang/rust:nightly
variables:
RUSTDOCFLAGS: >-
-Z unstable-options
--extern-html-root-url glib=https://gtk-rs.org/docs
--extern-html-root-url gio=https://gtk-rs.org/docs
script:
- make merge-lgpl-docs
- cargo doc --verbose --workspace --features dox --no-deps
- cp -r target/doc public
artifacts:
paths:
- public
only:
- main

# publish
publish_ostree-sys:
stage: publish
extends: .rust-ostree-devel
script:
- cargo publish --verbose --manifest-path sys/Cargo.toml --token $CRATES_IO_TOKEN
only:
- /^ostree-sys\/.+$/

publish_ostree:
stage: publish
extends: .rust-ostree-devel
script:
- cargo publish --verbose --token $CRATES_IO_TOKEN
only:
- /^ostree\/.+$/
93 changes: 93 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
[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 = [
"conf/**",
"gir-files/**",
"sys/**",
".gitlab-ci.yml",
"LICENSE.LGPL*",
]

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

[lib]
name = "ostree"

[workspace]
members = [".", "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 = "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"]
21 changes: 21 additions & 0 deletions rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM registry.fedoraproject.org/fedora:latest

RUN dnf install -y gcc git make 'dnf-command(builddep)'
RUN dnf builddep -y ostree

ARG OSTREE_REPO
ARG OSTREE_VERSION
RUN mkdir /src && \
cd /src && \
git init . && \
git fetch --depth 1 $OSTREE_REPO $OSTREE_VERSION && \
git checkout FETCH_HEAD && \
git submodule update --init
RUN mkdir /build && \
cd /build && \
NOCONFIGURE=1 /src/autogen.sh && \
/src/configure \
--with-openssl \
--with-curl \
&& \
make -j4
21 changes: 21 additions & 0 deletions rust/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 bbc3242

Please sign in to comment.