Skip to content

Commit

Permalink
twoliter: Create a test project
Browse files Browse the repository at this point in the history
  • Loading branch information
ecpullen committed Oct 30, 2023
1 parent 6795466 commit 7bf1975
Show file tree
Hide file tree
Showing 28 changed files with 416 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/projects/project1/.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/project1/.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/project1/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/project1/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/project1/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/project1/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/project1/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/project1/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/project1/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/project1/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/project1/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/project1/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/project1/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/project1/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/project1/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/project1/sources/clarify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

43 changes: 43 additions & 0 deletions tests/projects/project1/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/project1/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/project1/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/project1/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/project1/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/project1/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
27 changes: 27 additions & 0 deletions tests/projects/project1/variants/Cargo.lock

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

10 changes: 10 additions & 0 deletions tests/projects/project1/variants/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[workspace]
resolver = "1"
members = ["hello-ootb"]

[profile.dev]
debug = false
opt-level = 'z'

[profile.dev.build-override]
opt-level = 'z'
9 changes: 9 additions & 0 deletions tests/projects/project1/variants/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(())
}
Loading

0 comments on commit 7bf1975

Please sign in to comment.