Skip to content

Commit

Permalink
twoliter: create initial project with kits
Browse files Browse the repository at this point in the history
  • Loading branch information
ecpullen committed Dec 7, 2023
1 parent c506940 commit 8dcf636
Show file tree
Hide file tree
Showing 32 changed files with 432 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/projects/local-kit/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/.git
/.gomodcache
/build/*
!/build/rpms/
/build/rpms/*
!/build/rpms/*.rpm
/build/rpms/*-debuginfo-*.rpm
/build/rpms/*-debugsource-*.rpm
**/target/*
/sbkeys
10 changes: 10 additions & 0 deletions tests/projects/local-kit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/build/
**/target/
/.cargo/
/.gomodcache/
/keys/
/roles/
/sbkeys/
Test.toml
testsys.kubeconfig
Infra.toml
1 change: 1 addition & 0 deletions tests/projects/local-kit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This project represents a project structure with a single local kit with no external kit dependencies.
1 change: 1 addition & 0 deletions tests/projects/local-kit/Release.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "0.0.1"
11 changes: 11 additions & 0 deletions tests/projects/local-kit/Twoliter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
schema-version = 1

[sdk]
registry = "twoliter.alpha"
name = "bottlerocket-sdk"
version = "latest"

[toolchain]
registry = "public.ecr.aws/bottlerocket"
name = "bottlerocket-toolchain"
version = "v0.34.1"
9 changes: 9 additions & 0 deletions tests/projects/local-kit/kits/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use std::process::{exit, Command};

fn main() -> Result<(), std::io::Error> {
let ret = Command::new("buildsys").arg("build-variant").status()?;
if !ret.success() {
exit(1);
}
Ok(())
}
22 changes: 22 additions & 0 deletions tests/projects/local-kit/kits/hello-kit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "hello-kit"
version = "0.1.0"
edition = "2021"
publish = false
build = "../build.rs"
# Don't rebuild crate just because of changes to README.
exclude = ["README.md"]

[package.metadata.build-kit]
included-packages = [
# in-tree packages
"hello-agent",
"hello-go",
]

[lib]
path = "../kits.rs"

[build-dependencies]
hello-agent = { path = "../../packages/hello-agent" }
hello-go = { path = "../../packages/hello-go" }
7 changes: 7 additions & 0 deletions tests/projects/local-kit/kits/kits.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*!
This is an intentionally empty file that all of the variant `Cargo.toml` files can point to as their
`lib.rs`. The build system uses `build.rs` to invoke `buildsys` but Cargo needs something to compile
so we give it an empty `lib.rs` file.
!*/
9 changes: 9 additions & 0 deletions tests/projects/local-kit/packages/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use std::process::{exit, Command};

fn main() -> Result<(), std::io::Error> {
let ret = Command::new("buildsys").arg("build-package").status()?;
if !ret.success() {
exit(1);
}
Ok(())
}
21 changes: 21 additions & 0 deletions tests/projects/local-kit/packages/hello-agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "hello-agent"
version = "0.1.0"
edition = "2021"
publish = false
build = "../build.rs"

[package.metadata.build-package]
variant-sensitive = false
source-groups = ["hello-agent"]

[lib]
path = "../packages.rs"

# RPM BuildRequires
[build-dependencies]
# None

# RPM Requires
[dependencies]
# None
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Send a hello-agent Ping

[Service]
Type=oneshot
RemainAfterExit=false
StandardError=journal+console
ExecStart=/usr/bin/hello-agent
TimeoutStartSec=30s
44 changes: 44 additions & 0 deletions tests/projects/local-kit/packages/hello-agent/hello-agent.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
%global _cross_first_party 1
%undefine _debugsource_packages

Name: %{_cross_os}hello-agent
Version: 0.0
Release: 0%{?dist}
Summary: Hello-agent
License: Apache-2.0 OR MIT
URL: https://github.com/bottlerocket-os/bottlerocket

# sources < 100: misc

# 1xx sources: systemd units
Source103: hello-agent.service
Source104: hello-agent.timer

BuildRequires: %{_cross_os}glibc-devel

%description
%{summary}.

%prep
%setup -T -c
%cargo_prep

%build
mkdir bin

%cargo_build_static --manifest-path %{_builddir}/sources/Cargo.toml \
-p hello-agent

%install
install -d %{buildroot}%{_cross_bindir}
install -p -m 0755 ${HOME}/.cache/.static/%{__cargo_target_static}/release/hello-agent %{buildroot}%{_cross_bindir}

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 \
%{S:103} %{S:104} \
%{buildroot}%{_cross_unitdir}

%files
%{_cross_bindir}/hello-agent
%{_cross_unitdir}/hello-agent.service
%{_cross_unitdir}/hello-agent.timer
19 changes: 19 additions & 0 deletions tests/projects/local-kit/packages/hello-agent/hello-agent.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=Scheduled Hello-Agent Pings

[Timer]
# Don't run missed executions
Persistent=false
# Run 5 seconds after startup
OnStartupSec=5
# Run every 5 sec thereafter
OnUnitActiveSec=5
# Don't fire at exactly the same second across machines started together.
RandomizedDelaySec=1
# We don't want to extend the startup report too long after the requested time.
AccuracySec=1
# File describing job to execute
Unit=hello-agent.service

[Install]
WantedBy=timers.target
20 changes: 20 additions & 0 deletions tests/projects/local-kit/packages/hello-go/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "hello-go"
version = "0.1.0"
edition = "2021"
publish = false
build = "../build.rs"

[package.metadata.build-package]
source-groups = ["hello-go"]

[lib]
path = "../packages.rs"

# RPM BuildRequires
[build-dependencies]
# None

# RPM Requires
[dependencies]
# None
9 changes: 9 additions & 0 deletions tests/projects/local-kit/packages/hello-go/hello-go.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Send a hello-go Ping

[Service]
Type=oneshot
RemainAfterExit=false
StandardError=journal+console
ExecStart=/usr/bin/hello-go
TimeoutStartSec=30s
43 changes: 43 additions & 0 deletions tests/projects/local-kit/packages/hello-go/hello-go.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
%global _cross_first_party 1
%undefine _debugsource_packages

Name: %{_cross_os}hello-go
Version: 0.0
Release: 0%{?dist}
Summary: hello-go
License: Apache-2.0 OR MIT
URL: https://github.com/bottlerocket-os/bottlerocket

# sources < 100: misc

# 1xx sources: systemd units
Source103: hello-go.service
Source104: hello-go.timer

BuildRequires: %{_cross_os}glibc-devel
Requires: %{_cross_os}hello-go

%description
%{summary}.

%prep
%setup -T -c
cp -r %{_builddir}/sources/hello-go/* .

%build
%set_cross_go_flags
go build -buildmode=pie -ldflags="${GOLDFLAGS}" -o hello-go ./cmd/hello-go

%install
install -d %{buildroot}%{_cross_bindir}
install -p -m 0755 hello-go %{buildroot}%{_cross_bindir}

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 \
%{S:103} %{S:104} \
%{buildroot}%{_cross_unitdir}

%files
%{_cross_bindir}/hello-go
%{_cross_unitdir}/hello-go.service
%{_cross_unitdir}/hello-go.timer
19 changes: 19 additions & 0 deletions tests/projects/local-kit/packages/hello-go/hello-go.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=Scheduled Hello-Go Pings

[Timer]
# Don't run missed executions
Persistent=false
# Run 120 seconds after startup
OnStartupSec=5
# Run every 5 sec thereafter
OnUnitActiveSec=5
# Don't fire at exactly the same second across machines started together.
RandomizedDelaySec=1
# We don't want to extend the startup report too long after the requested time.
AccuracySec=1
# File describing job to execute
Unit=hello-go.service

[Install]
WantedBy=timers.target
7 changes: 7 additions & 0 deletions tests/projects/local-kit/packages/packages.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*!
This is an intentionally empty file that all of the package `Cargo.toml` files can point to as their
`lib.rs`. The build system uses `build.rs` to invoke `buildsys` but Cargo needs something to compile
so we give it an empty `lib.rs` file.
!*/
7 changes: 7 additions & 0 deletions tests/projects/local-kit/sources/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/projects/local-kit/sources/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[workspace]
resolver = "1"
members = ["hello-agent"]
1 change: 1 addition & 0 deletions tests/projects/local-kit/sources/clarify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

43 changes: 43 additions & 0 deletions tests/projects/local-kit/sources/deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[licenses]
unlicensed = "deny"

# Deny licenses unless they are specifically listed here
copyleft = "deny"
allow-osi-fsf-free = "neither"
default = "deny"

# We want really high confidence when inferring licenses from text
confidence-threshold = 0.93

# Commented license types are allowed but not currently used
allow = [
"Apache-2.0",
# "BSD-2-Clause",
# "BSD-3-Clause",
# "BSL-1.0",
# "CC0-1.0",
# "ISC",
"MIT",
# "OpenSSL",
# "Unlicense",
# "Zlib",
]

exceptions = []


[bans]
# Deny multiple versions or wildcard dependencies.
multiple-versions = "deny"
wildcards = "deny"

deny = [{ name = "structopt" }, { name = "clap", wrappers = ["cargo-readme"] }]

skip = []

skip-tree = []

[sources]
# Deny crates from unknown registries or git repositories.
unknown-registry = "deny"
unknown-git = "deny"
7 changes: 7 additions & 0 deletions tests/projects/local-kit/sources/hello-agent/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "hello-agent"
version = "0.1.0"
authors = ["Ethan Pullen <[email protected]>"]
license = "Apache-2.0 OR MIT"
edition = "2021"
publish = false
1 change: 1 addition & 0 deletions tests/projects/local-kit/sources/hello-agent/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
6 changes: 6 additions & 0 deletions tests/projects/local-kit/sources/hello-agent/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use std::process;

fn main() -> ! {
println!("Hello from hello-agent");
process::exit(0)
}
11 changes: 11 additions & 0 deletions tests/projects/local-kit/sources/hello-go/cmd/hello-go/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"fmt"
"os"
)

func main() {
fmt.Println("Hello Go")
os.Exit(0)
}
3 changes: 3 additions & 0 deletions tests/projects/local-kit/sources/hello-go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module hello-go

go 1.19
Loading

0 comments on commit 8dcf636

Please sign in to comment.