Skip to content

Commit

Permalink
self_test_img subproject
Browse files Browse the repository at this point in the history
  • Loading branch information
pwalski committed Jul 21, 2023
1 parent d5a91ba commit 0c8353a
Show file tree
Hide file tree
Showing 8 changed files with 338 additions and 8 deletions.
67 changes: 59 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,62 @@ jobs:
path: |
runtime/init-container/initramfs.cpio.gz
runtime/init-container/vmlinuz-virt
build-self-test-img:
name: Build self test image
runs-on: ubuntu-20.04
env:
gvmkit-build_tag: v0.3.13
gvmkit-build_dir: gvmkit-build
gvmkit-build_archive: gvmkit-build-x86_64-unknown-linux-gnu.tar.gz
self-test-img_tag: self-test
rust_stable: 1.70.0
defaults:
run:
working-directory: self_test_img

steps:
- uses: actions/checkout@v3

- name: Install Rust ${{ env.rust_stable }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.rust_stable }}
components: rustfmt, clippy

- name: Check lockfile
uses: actions-rs/cargo@v1
with:
command: tree
args: --locked

- name: Build Docker image for GPU
uses: docker/build-push-action@v4
with:
push: false
tags: ${{ env.self-test-img_tag }}

- name: Download gvmkit-build
if: startsWith(github.ref, 'refs/tags/')
uses: robinraju/[email protected]
with:
repository: golemfactory/gvmkit-build-rs
tag: ${{ env.gvmkit-build_tag }}
fileName: ${{ env.gvmkit-build_archive }}
extract: true
out-file-path: ${{ env.gvmkit-build_dir }}
tarBall: false
zipBall: false

- name: Build GVMkit image
if: startsWith(github.ref, 'refs/tags/')
run: |
${{ env.gvmkit-build_dir }}/gvmkit-build ${{ env.self-test-img_tag }}:latest -o ${{ env.self-test-img_gvmi }}
- uses: actions/upload-artifact@v2
with:
name: self_test_img
path: |
${{ env.self-test-img_gvmi }}
build:
name: Build Release
Expand All @@ -85,15 +141,10 @@ jobs:
- run: |
ls -R
test -f runtime/init-container/initramfs.cpio.gz
- name: Download self-test image
uses: robinraju/[email protected]
- uses: actions/download-artifact@v2
with:
repository: ${{ env.self-test-img_repository }}
tag: ${{ env.self-test-img_tag }}
fileName: self-test.gvmi
out-file-path: runtime/image/
tarBall: false
zipBall: false
name: self_test_img
path: runtime/image/
- name: Install Musl
run: |
sudo apt-get install -y musl-tools musl
Expand Down
4 changes: 4 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"runtime",
"gvmkit",
"self_test_img"
]

[patch.crates-io]
Expand Down
228 changes: 228 additions & 0 deletions self_test_img/Cargo.lock

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

8 changes: 8 additions & 0 deletions self_test_img/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "ya-self-test"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "ya-self-test"
path = "src/main.rs"
13 changes: 13 additions & 0 deletions self_test_img/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM rust:1.70.0 as rust_builder
RUN rustup target add x86_64-unknown-linux-musl

FROM rust_builder as builder
WORKDIR /data
COPY . .
RUN cargo install --path . --target x86_64-unknown-linux-musl

FROM scratch
VOLUME [ "/mnt/out" ]
WORKDIR /
COPY --from=builder /usr/local/cargo/bin/ya-self-test /ya-self-test
CMD [ "/ya-self-test" ]
12 changes: 12 additions & 0 deletions self_test_img/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
all: build

build: src
docker build -t self-test .
gvmkit-build self-test:latest -o self-test.gvmi

.PHONY: all

.PHONY: clean
clean:
cargo clean
rm -f self-test.gvmi
13 changes: 13 additions & 0 deletions self_test_img/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use std::{env, fs};

fn main() {
let args: Vec<String> = env::args().collect();

let output = "{}";

if args.len() == 2 {
fs::write(&args[1], output).expect("Unable to write file");
} else {
print!("{}", output);
}
}

0 comments on commit 0c8353a

Please sign in to comment.