Skip to content

Commit

Permalink
ci: trying new CI config (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
hironichu authored Sep 19, 2023
1 parent e61c837 commit d52a1ec
Show file tree
Hide file tree
Showing 17 changed files with 267 additions and 361 deletions.
212 changes: 103 additions & 109 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,65 +18,34 @@ concurrency:
name: Webtransport CI
jobs:
build:
name: ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}
if: |
github.event_name == 'push' ||
!startsWith(github.event.pull_request.head.label, 'hironichu:')
runs-on: ${{ matrix.os }}
timeout-minutes: 90
github.event_name == 'push' || !startsWith(github.event.pull_request.head.label, 'hironichu:')
strategy:
matrix:
os: [ 'ubuntu-latest', 'self-hosted']
job: [build]
profile: [debug, release]
include:
- os: macos-latest
job: test
profile: debug
- os: macos-latest
job: test
profile: release
- os: windows-latest
job: test
profile: debug
- os: windows-latest
job: test
profile: release
- os: 'ubuntu-22.04'
job: test
profile: release
use_sysroot: true
- os: 'ubuntu-22.04'
job: test
profile: debug

- os: 'ubuntu-22.04'
- os: 'ubuntu-latest'
job: lint
profile: debug

- os: 'self-hosted'
job: test
profile: debug

- os: 'self-hosted'
job: test
profile: release
fail-fast: ${{ github.event_name == 'pull_request' || (github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')) }}
name: ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 10
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
steps:
- name: Configure git
run: |
git config --global core.symlinks true
git config --global fetch.parallel 4
- name: Clone repository
uses: actions/checkout@v3
with:
fetch-depth: 2
submodules: recursive
- name: Create source tarballs (release, linux)
if: |
startsWith(matrix.os, 'ubuntu') &&
matrix.profile == 'release' &&
matrix.job == 'test' &&
matrix.job == 'build' &&
github.repository == 'hironichu/webtransport' &&
startsWith(github.ref, 'refs/tags/')
run: |
Expand All @@ -86,9 +55,10 @@ jobs:
- name: Setting Up Rust
uses: dtolnay/rust-toolchain@master
if: |
matrix.job != 'lint'
with:
toolchain: nightly

toolchain: stable
- name: Install Deno from .land
if: matrix.os != 'self-hosted'
uses: denoland/setup-deno@v1
Expand All @@ -108,37 +78,6 @@ jobs:
- name: Error on warning
run: echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV

- name: Log versions
shell: bash
run: |
rustc --version
cargo --version
deno --version
- name: Cache build output (main)
uses: actions/cache@v3
if: (matrix.job == 'test' && matrix.profile == 'release') &&
github.ref == 'refs/heads/main'
with:
path: |
!./target/*/*.dll
!./target/*/*.so
!./target/*/*.dylib
key: |
16-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ github.sha }}
- name: Cache build output (PR)
uses: actions/cache@v3
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') &&
matrix.job == 'test' && matrix.profile == 'release'
with:
path: |
!./target/*/*.dll
!./target/*/*.so
!./target/*/*.dylib
key: never_saved
restore-keys: |
16-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-
- name: Deno Format
if: matrix.job == 'lint'
run: deno task util:fmt
Expand All @@ -149,34 +88,104 @@ jobs:

- name: Build Debug
if: |
(!startsWith(matrix.os, 'self-hosted')) &&
(matrix.job == 'test' && matrix.profile == 'debug')
run: deno task build:debug

- name: Build Debug ARM
if: |
(startsWith(matrix.os, 'self-hosted')) &&
(matrix.job == 'test' && matrix.profile == 'debug')
run: |
deno task build:debug-arm
(matrix.job == 'build' && matrix.profile == 'debug')
run: deno task build:${{matrix.profile}}

- name: Build release
if: |
(!startsWith(matrix.os, 'self-hosted')) &&
(matrix.job == 'test' && matrix.profile == 'release') &&
(matrix.job == 'build' && matrix.profile == 'release') &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
run: deno task build:release
run: deno task build:${{matrix.profile}}

- name: Build release Linux ARM
- name: Move arm file (release)
if: startsWith(matrix.os, 'self-hosted') && matrix.job == 'build' && matrix.profile == 'release' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
run: |
mv target/${{matrix.profile}}/libwebtransport.so target/${{matrix.profile}}/libwebtransport_aarch64.so
- name: Move arm file (debug)
if: startsWith(matrix.os, 'self-hosted') && matrix.job == 'build' && matrix.profile == 'debug'
run: |
mv target/${{matrix.profile}}/libwebtransport.so target/${{matrix.profile}}/libwebtransport_aarch64.so
- name: Upload artifact (release)
uses: actions/upload-artifact@master
if: |
(matrix.job == 'build' && matrix.profile == 'release') &&
((github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')))
with:
name: release
path: |
target/${{matrix.profile}}/webtransport.dll
target/${{matrix.profile}}/libwebtransport.so
target/${{matrix.profile}}/libwebtransport_aarch64.so
target/${{matrix.profile}}/libwebtransport.dylib
- name: Upload artifact (debug)
uses: actions/upload-artifact@master
if: |
matrix.job == 'build' && matrix.profile == 'debug' && !startsWith(github.ref, 'refs/tags/')
with:
name: debug
path: |
target/${{matrix.profile}}/webtransport.dll
target/${{matrix.profile}}/libwebtransport.so
target/${{matrix.profile}}/libwebtransport_aarch64.so
target/${{matrix.profile}}/libwebtransport.dylib
- name: Upload release to GitHub
uses: softprops/action-gh-release@59c3b4891632ff9a897f99a91d7bc557467a3a22
if: |
(startsWith(matrix.os, 'self-hosted')) &&
(matrix.job == 'test' && matrix.profile == 'release') && (matrix.use_sysroot ||
(github.repository == 'hironichu/webtransport' &&
(github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/tags/'))))
(matrix.job == 'build' && matrix.profile == 'release') &&
github.repository == 'hironichu/webtransport' &&
github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
target/${{matrix.profile}}/webtransport.dll
target/${{matrix.profile}}/libwebtransport.so
target/${{matrix.profile}}/libwebtransport_aarch64.so
target/${{matrix.profile}}/libwebtransport.dylib
draft: true
test:
needs: build
if: |
github.event_name == 'push' || !startsWith(github.event.pull_request.head.label, 'hironichu:')
strategy:
matrix:
os: [ 'ubuntu-latest', 'self-hosted']
job: [test]
profile: [debug, release]
name: ${{ matrix.job }} ${{ matrix.profile }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 5

steps:
- uses: actions/checkout@master
- name: Creating target structure
run: |
deno task build:release-arm
mkdir -p target
- name: Download artifact
uses: actions/download-artifact@master
with:
path: target

- name: Display structure of downloaded files
run: ls -R
- name: Install Deno from .land
if: matrix.os != 'self-hosted'
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Install Deno from source
if: matrix.os == 'self-hosted'
run: |
echo "Check if Deno is already installed"
if ! type deno > /dev/null; then
echo "Deno is not installed, installing..."
curl -s https://gist.githubusercontent.com/LukeChannings/09d53f5c364391042186518c8598b85e/raw/ac8cd8c675b985edd4b3e16df63ffef14d1f0e24/deno_install.sh | sh
else
echo "Deno is already installed"
fi
- name: Run deno test (debug)
if: |
matrix.job == 'test' && matrix.profile == 'debug' && !startsWith(github.ref, 'refs/tags/')
Expand All @@ -194,19 +203,4 @@ jobs:
BUILD_TARGET: release
DEVELOPMENT: true
run: |
deno task test
- name: Upload release to GitHub
uses: softprops/action-gh-release@59c3b4891632ff9a897f99a91d7bc557467a3a22
if: |
(matrix.job == 'test' && matrix.profile == 'release') &&
github.repository == 'hironichu/webtransport' &&
github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
dist/webtransport.dll
dist/libwebtransport.so
dist/libwebtransport_aarch64.so
dist/libwebtransport.dylib
draft: true
deno task test
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "webtransport"
name = "Webtransport"
description = "Deno WebTransport FFI library for Deno"
version = "0.1.0"
edition = "2021"
Expand Down Expand Up @@ -47,6 +47,7 @@ tokio = { version = "=1.32.0", default-features = false, features = [
wtransport = { git = "https://github.com/hironichu/wtransport", branch = "feat/new", features = [
"dangerous-configuration",
] }
wtransport-proto = { git = "https://github.com/hironichu/wtransport", branch = "feat/new" }
rcgen = "=0.11.1"
ring = "=0.16.20"
time = "=0.3.28"
Expand Down
13 changes: 6 additions & 7 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
"example:web": "deno run -A ./examples/web_server/web.js",
"example:server": "deno run -A --unstable ./examples/deno/wt_server.ts",
"example:client": "deno run -A --unstable ./examples/deno/wt_client.ts",
// Build task
"build:release": "deno task util:clean && cargo build --out-dir ./dist -Z unstable-options --release",
"build:release-arm": "deno task util:clean && cargo build --out-dir ./dist -Z unstable-options --release && mv ./dist/libwebtransport.so ./dist/libwebtransport_aarch64.so",
"build:debug": "deno task util:clean && cargo build --out-dir ./dist -Z unstable-options",
"build:debug-arm": "deno task util:clean && cargo build --out-dir ./dist -Z unstable-options && mv ./dist/libwebtransport.so ./dist/libwebtransport_aarch64.so",
// CI Build task
"build:release": "cargo clean && cargo build --release",
"build:debug": "cargo clean && cargo build",
//Utils
"util:clean": "deno run --allow-write --allow-read ./utils/clean.js",
"util:fmt": "deno fmt --unstable",
"util:lint": "deno lint --unstable",
//Tests
"test": "deno test -A --unstable examples/deno/wt_server_test.ts"
"test": "deno test -A --unstable ",
//Non CI build
"build": "cargo build"
},
"compilerOptions": {
"checkJs": true,
Expand Down
1 change: 1 addition & 0 deletions examples/deno/wt_client_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Deno.test(
sanitizeResources: false,
},
async () => {
//THis causes panic???????
// const server = new WebTransportServer(4433, {
// certFile: "./certs/cert.pem",
// keyFile: "./certs/key.pem",
Expand Down
72 changes: 49 additions & 23 deletions examples/deno/wt_server_test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,51 @@
import "../../mod/mod.ts";
Deno.test({ name: "Server startup/close" }, async () => {
const server = new WebTransportServer(4433, {
certFile: "./certs/cert.pem",
keyFile: "./certs/key.pem",
maxTimeout: 10,
keepAlive: 3,
});
// import { join } from "https://deno.land/[email protected]/path/mod.ts";
// import { GenerateCertKeyFile } from "../../mod/crypto.ts";
// import "../../mod/mod.ts";
// import { assert } from "https://deno.land/[email protected]/assert/assert.ts";

await server.close();
});
// //add certs cleanup methods after tests
// const certPath = join(Deno.cwd(), "./certs/");
// Deno.test({ name: "Server startup/close" }, () => {
// //generate a certificate
// const [cert, key] = GenerateCertKeyFile(
// "localhost",
// 0,
// 10,
// undefined,
// "cert.pem",
// "key.pem",
// );
// const server = new WebTransportServer(4433, {
// certFile: cert,
// keyFile: key,
// maxTimeout: 10,
// keepAlive: 3,
// });
// server.close();
// //try to start a UDP socket on the same port to see if it's closed
// const sock = Deno.listenDatagram({
// hostname: "0.0.0.0",
// port: 4433,
// transport: "udp",
// });
// assert(sock, "Server did not close");
// sock.close();
// });

// Deno.test(
// { name: "Server with generated certificate startup/close" },
// async () => {
// const server = new WebTransportServer(4434, {
// maxTimeout: 10,
// keepAlive: 3,
// notAfter: 10,
// notBefore: 0,
// domain: "localhost",
// });
// await server.close();
// },
// );
// // Deno.test(
// // { name: "Server with generated certificate startup/close" },
// // () => {
// // const server = new WebTransportServer(4433, {
// // maxTimeout: 10,
// // keepAlive: 3,
// // notAfter: 10,
// // notBefore: 0,
// // domain: "localhost",
// // });
// // server.close();
// // },
// // );

// Deno.test({ name: "Server Cleanup certs" }, () => {
// Deno.removeSync(certPath, { recursive: true });
// });
Loading

0 comments on commit d52a1ec

Please sign in to comment.