-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add github actions tests on k3d + release setup
Signed-off-by: clux <[email protected]>
- Loading branch information
Showing
10 changed files
with
281 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: [clux] | ||
#patreon: # Replace with a single Patreon username | ||
#open_collective: # Replace with a single Open Collective username | ||
#ko_fi: # Replace with a single Ko-fi username | ||
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
#liberapay: # Replace with a single Liberapay username | ||
#issuehunt: # Replace with a single IssueHunt username | ||
#otechie: # Replace with a single Otechie username | ||
#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
cargo-test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
override: true | ||
toolchain: stable | ||
profile: minimal | ||
- uses: Swatinem/rust-cache@v1 | ||
- uses: nolar/setup-k3d-k3s@v1 | ||
with: | ||
version: v1.21 | ||
k3d-name: kube | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
- run: kubectl apply --force-conflicts --server-side -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.52.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml | ||
- run: cargo build --all | ||
- run: cargo run --bin kopium -- prometheusrules.monitoring.coreos.com > gen.rs | ||
- run: echo "pub type CR = PrometheusRule;" >> gen.rs | ||
- run: kubectl apply -f test.yaml | ||
- run: cargo run --bin tester -- PrometheusRule | ||
|
||
|
||
rustfmt: | ||
name: Run rustfmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/[email protected] | ||
with: | ||
profile: minimal | ||
toolchain: nightly | ||
components: rustfmt | ||
override: true | ||
- name: Run rustfmt | ||
id: rustfmt | ||
run: rustfmt +nightly --edition 2018 --check $(find . -type f -iname *.rs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: Release | ||
|
||
on: | ||
pull_request: | ||
#push: | ||
# tags: | ||
# - 'v[0-9]+.[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- x86_64-unknown-linux-musl | ||
- x86_64-apple-darwin | ||
include: | ||
- target: x86_64-unknown-linux-musl | ||
os: ubuntu-latest | ||
- target: x86_64-apple-darwin | ||
os: macos-latest | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Build Linux | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
docker run --rm -t \ | ||
-v $HOME/.cargo/registry/:/root/.cargo/registry \ | ||
-v "$(pwd)":/volume \ | ||
clux/muslrust:stable \ | ||
cargo build --release --target ${{ matrix.target }} | ||
- name: Prepare macOS | ||
if: matrix.os == 'macos-latest' | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
target: ${{ matrix.target }} | ||
override: true | ||
- name: Build macOS | ||
if: matrix.os == 'macos-latest' | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
toolchain: stable | ||
command: build | ||
args: --release --target ${{ matrix.target }} | ||
- name: Upload | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: kopium-${{ matrix.os }}-amd64 | ||
path: target/${{ matrix.target }}/release/kopium | ||
if-no-files-found: error | ||
|
||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Download | ||
uses: actions/download-artifact@v2 | ||
- name: Layout | ||
run: | | ||
mv kopium-ubuntu-latest-amd64/kopium ./kopium-linux-amd64 | ||
mv kopium-macos-latest-amd64/kopium ./kopium-darwin-amd64 | ||
rm -rf kopium-ubuntu-latest-amd64 kopium-macos-latest-amd64 | ||
- name: Checksum | ||
run: make SHA256SUMS | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
- name: Release SHA256SUMS | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: SHA256SUMS | ||
asset_name: SHA256SUMS | ||
asset_content_type: text/plain | ||
- name: Release kopium-linux-amd64 | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_name: kopium-linux-amd64 | ||
asset_path: kopium-linux-amd64 | ||
asset_content_type: application/octet-stream | ||
- name: Release kopium-macos-amd64 | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: kopium-darwin-amd64 | ||
asset_name: kopium-darwin-amd64 | ||
asset_content_type: application/octet-stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
gen.rs |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use anyhow::Result; | ||
use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::{ | ||
CustomResourceDefinition | ||
}; | ||
use kube::{Api, Client, Resource, ResourceExt}; | ||
|
||
include!("./gen.rs"); // import generated test structs in scope | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let client = Client::try_default().await?; | ||
|
||
let api: Api<CustomResourceDefinition> = Api::all(client.clone()); | ||
let cr: Api<CR> = Api::default_namespaced(client); | ||
|
||
println!("crd gvk {}-{}-{}", CR::group(&()), CR::version(&()), CR::kind(&())); | ||
let canonical = api.get(&format!("{}.{}", CR::plural(&()), CR::group(&()))).await?; | ||
assert_eq!(canonical.spec.names.kind, CR::kind(&()).to_string()); | ||
assert_eq!(canonical.spec.names.plural, CR::plural(&()).to_string()); | ||
assert_eq!(canonical.spec.group, CR::group(&()).to_string()); | ||
|
||
// assumes a resource of type CR has been applied with name 'gen' in the namespace | ||
let crd = cr.get("gen").await?; | ||
assert_eq!(crd.name(), "gen"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: PrometheusRule | ||
metadata: | ||
name: gen | ||
spec: | ||
groups: | ||
- name: ./pr.rules | ||
rules: | ||
- alert: PRFakeAlert | ||
labels: | ||
severity: info | ||
expr: "0" | ||
for: 10m | ||
annotations: | ||
summary: "Parsing this" |