diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..1d16d7a8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +name: CI + +on: + push: + branches: + - trying + - staging + +jobs: + test: + strategy: + matrix: + os: ["ubuntu-latest", "windows-latest", "macos-latest"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.54.0 + profile: minimal + components: rustfmt, clippy + + - uses: actions/setup-node@v2 + if: matrix.os == 'windows-latest' + with: + node-version: '16' + + - name: Test + if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' + env: + CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: sudo -E + CARGO_TARGET_X86_64_APPLE_DARWIN_RUNNER: sudo -E + RUSTFLAGS: -D warnings + run: cargo test --all --all-targets --all-features --locked + + - name: Integration Test + if: matrix.os == 'ubuntu-latest' + run: | + set -ex + sudo apt-get update + sudo apt-get install -yqq wireguard net-tools + cargo build + cd ns-test + sudo ./integration-test.sh + sudo ./interop-test.sh + + - name: Test + if: matrix.os == 'windows-latest' + shell: bash + env: + RUSTFLAGS: -D warnings + TESTING: 1 + run: | + set -ex + cd windows-gui-client && yarn && yarn build && cd .. + cargo test --all --all-targets --locked + + - name: Check Fuzz + if: matrix.os == 'ubuntu-latest' + run: cd fuzz && cargo check --locked + + - name: Fmt check + if: matrix.os == 'macos-latest' + run: | + set -ex + cargo fmt --all -- --check + cargo run --example check-copyright + cd fuzz && cargo fmt -- --check + + - name: Clippy + run: cargo clippy --all --all-targets -- -D clippy::all diff --git a/.github/workflows/dependabot-update-fuzz-too.yml b/.github/workflows/dependabot-update-fuzz-too.yml deleted file mode 100644 index 1085a54d..00000000 --- a/.github/workflows/dependabot-update-fuzz-too.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: update fuzz - -on: - push: - branches: dependabot/cargo/* - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - profile: minimal - - name: Update fuzz - run: | - cd fuzz - cargo check - git config --global user.name "Yin Guanhao" - git config --global user.email "sopium@users.noreply.github.com" - git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY - git checkout "${GITHUB_REF:11}" - git add . - git commit --amend --no-edit || exit 0 - git status - git push --force-with-lease diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..f4d4634e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + strategy: + matrix: + os: ["ubuntu-latest", "windows-latest", "macos-latest"] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: 1.54.0 + profile: minimal + components: rustfmt, clippy + + - uses: actions/setup-node@v2 + if: matrix.os == 'windows-latest' + with: + node-version: '16' + + - if: matrix.os == 'windows-latest' + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Build (Windows) + if: matrix.os == 'windows-latest' + run: | + cd windows-gui-client && yarn && yarn build && cd .. + cargo build --release + msbuild windows-gui-installer/titun-windows-gui-installer.sln /property:Configuration=Release /property:Platform=x64 + cp windows-gui-installer/installer/bin/Release/titun.msi titun-$(uname -m).msi + + - name: Build (linux/macos) + if: matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' + run: cargo build --release && xz --stdout target/release/titun > target/release/titun-$(uname -m)-${{ matrix.os == 'ubuntu-latest' && 'linux' || 'macos' }}.xz + + - name: Release + uses: softprops/action-gh-release@v1 + with: + draft: true + files: | + target/release/titun-* + titun-*.msi diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index f18381b0..00000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,217 +0,0 @@ -# Starter pipeline -# Start with a minimal pipeline that you can customize to build and deploy your code. -# Add steps that build, run tests, deploy, and more: -# https://aka.ms/yaml - -trigger: -- staging -- trying - -pr: none - -jobs: -# Check formatting -- job: rustfmt - displayName: Check foramtting - pool: - vmImage: ubuntu-20.04 - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable - - script: | - set -ex - rustup component add rustfmt - cargo fmt --version - displayName: Install rustfmt - - script: | - set -ex - cargo fmt --all -- --check - cd fuzz && cargo fmt -- --check - displayName: Check formatting - - script: cargo run --example check-copyright - displayName: Check copyright headers - -# Speed up CI by running clippy in its own jobs. -- job: clippy - displayName: clippy - pool: - vmImage: ubuntu-20.04 - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable - - script: | - rustup component add clippy && - cargo clippy --all-targets -- -D clippy::all - displayName: Run clippy - -- job: test - displayName: Test - pool: - vmImage: ubuntu-20.04 - variables: - # Use kcov to collect coverage. - RUSTFLAGS: -Clink-dead-code -D warnings - # CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: sudo -E kcov --verify --include-pattern=titun/src coverage - CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: sudo -E - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable - - script: | - set -ex - sudo apt-get update - sudo apt-get install -yqq wireguard net-tools - displayName: Install WireGuard Kernel Module and Tools - # - script: | - # set -ex - # sudo apt-get install -yqq libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc binutils-dev libiberty-dev - # wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz - # tar xzf master.tar.gz - # cd kcov-master - # mkdir build - # cd build - # cmake .. - # make - # sudo make install - # cd ../.. - # rm -rf kcov-master - # displayName: Install kcov - - script: cargo test --lib --benches --locked --features=sudo-tests - displayName: Run tests - - script: | - set -ex - cargo build - cd ns-test - sudo ./integration-test.sh - sudo ./interop-test.sh - displayName: Run Integration Test - # - script: bash <(curl -s https://codecov.io/bash) - # displayName: Upload code coverage info to codecov.io - -- job: macOS_test - displayName: Test on MacOS - variables: - # Deny warnings - RUSTFLAGS: -D warnings - pool: - vmImage: macOS-latest - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable-x86_64-apple-darwin - - script: cargo test --lib --benches --locked - displayName: Run tests - -- job: macOS_clippy - displayName: Clippy on MacOS - pool: - vmImage: macOS-latest - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable-x86_64-apple-darwin - - bash: | - rustup component add clippy && - cargo clippy --all-targets -- -D clippy::all - displayName: Run clippy - -- job: windows_clippy - displayName: Clippy on Windows - pool: - vmImage: windows-2019 - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable-x86_64-pc-windows-msvc - - bash: | - rustup component add clippy && - cargo clippy --all-targets -- -D clippy::all - displayName: Run clippy - -- job: windows_test - displayName: Test on Windows - variables: - # Deny warnings - RUSTFLAGS: -D warnings - pool: - vmImage: windows-2019 - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable-x86_64-pc-windows-msvc - - script: cargo test --lib --benches --locked - displayName: Run tests - -- job: check_fuzz - displayName: Check Fuzz - pool: - vmImage: ubuntu-20.04 - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable - - script: cd fuzz && cargo check --locked - displayName: Check fuzz - -- job: cross_test_aarch64 - displayName: Cross test for aarch64 - variables: - # Deny warnings - RUSTFLAGS: -D warnings - pool: - vmImage: ubuntu-20.04 - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable - - script: | - set -ex - rustup target add aarch64-unknown-linux-gnu - sudo apt-get update - sudo apt-get install -yqq gcc-aarch64-linux-gnu qemu-user-static - cargo test --locked --target aarch64-unknown-linux-gnu - env: - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER: qemu-aarch64-static -L /usr/aarch64-linux-gnu - displayName: Run tests - -- job: cross_test_mipsel - displayName: Cross test for mipsel - variables: - # Deny warnings - RUSTFLAGS: -D warnings - pool: - vmImage: ubuntu-20.04 - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable - - script: | - set -ex - rustup target add mipsel-unknown-linux-gnu - sudo apt-get update - sudo apt-get install -yqq gcc-mipsel-linux-gnu qemu-user-static - cargo test --locked --target mipsel-unknown-linux-gnu - env: - CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER: mipsel-linux-gnu-gcc - CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_RUNNER: qemu-mipsel-static -L /usr/mipsel-linux-gnu - displayName: Run tests - -- job: cross_check_freebsd - displayName: Cross check for freebsd - variables: - # Deny warnings - RUSTFLAGS: -D warnings - pool: - vmImage: ubuntu-20.04 - steps: - - template: ci/azure-install-rust.yml - parameters: - rust_version: stable - - script: | - set -ex - rustup target add x86_64-unknown-freebsd - cargo check --locked --all-targets --target x86_64-unknown-freebsd - displayName: Check diff --git a/bors.toml b/bors.toml index 07a439be..8748bfa2 100644 --- a/bors.toml +++ b/bors.toml @@ -1,2 +1,6 @@ -status = ["sopium.titun"] +status = [ + "test (ubuntu-latest)", + "test (windows-latest)", + "test (macos-latest)", +] delete_merged_branches = true