From 9168c33c7e9ec0a87e166812a46fd05d9c8d7cb2 Mon Sep 17 00:00:00 2001
From: John Nunley <dev@notgull.net>
Date: Mon, 25 Sep 2023 20:00:16 -0700
Subject: [PATCH] Port to sr.ht

Signed-off-by: John Nunley <dev@notgull.net>
---
 .build.yml | 17 +++++++++++++++
 ci/ci.sh   | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)
 create mode 100644 .build.yml
 create mode 100644 ci/ci.sh

diff --git a/.build.yml b/.build.yml
new file mode 100644
index 0000000..a01a001
--- /dev/null
+++ b/.build.yml
@@ -0,0 +1,17 @@
+image: alpine/edge
+packages:
+- clang
+- curl
+sources:
+- https://git.sr.ht/~notgull/theo
+secrets:
+- 424251f4-3b9e-4f8b-8361-e000fe6222f3
+tasks:
+- test: |
+    cd theo
+    curl https://sh.rustup.rs -sSf | sh -s -- -y
+    sh ci/ci.sh 
+- mirror: |
+    cd theo
+    git remote add github_origin git@github.com:notgull/theo.git
+    git push github_origin main
\ No newline at end of file
diff --git a/ci/ci.sh b/ci/ci.sh
new file mode 100644
index 0000000..0ff2f0b
--- /dev/null
+++ b/ci/ci.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -eu
+
+# Run CI-based tests for Theo
+
+rx() {
+  cmd="$1"
+  shift
+
+  (
+    set -x
+    "$cmd" "$@"
+  )
+}
+
+theo_test_version() {
+  version="$1"
+  extended_tests="$2"
+
+  rustup toolchain add "$version" --profile minimal
+  rustup default "$version"
+
+  echo ">> Testing various feature sets..."
+  rx cargo test
+  rx cargo build --all --all-features --all-targets
+  rx cargo build --no-default-features --features x11,gl,egl,glx,wgl
+  rx cargo build --no-default-features --features x11
+
+  if ! $extended_tests; then
+    return
+  fi
+  
+  echo ">> Build for wasm32-unknown-unknown..."
+  rustup target add wasm32-unknown-unknown
+  rx cargo build --target wasm32-unknown-unknown --no-default-features
+  rx cargo build --target wasm32-unknown-unknown --no-default-features --features gl
+
+  echo ">> Build for x86_64-pc-windows-gnu"
+  rustup target add x86_64-pc-windows-gnu
+  rx cargo build --target x86_64-pc-windows-gnu
+  rx cargo build --target x86_64-pc-windows-gnu --no-default-features --features gl,wgl,egl
+}
+
+theo_tidy() {
+  rustup toolchain add stable --profile minimal
+  rustup default stable
+
+  rx cargo fmt --all --check
+  rx cargo clippy --all-features --all-targets
+}
+
+if ! command -v rustup; then
+  rustup-init -y
+fi
+
+theo_tidy
+theo_test_version stable true
+theo_test_version beta true
+theo_test_version nightly true
+theo_test_version 1.65.0 false
+