Skip to content

Commit

Permalink
Refactor Build Workflow (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks authored Apr 4, 2022
1 parent c7309d7 commit 65706e4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 179 deletions.
213 changes: 35 additions & 178 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,207 +9,64 @@ on:
permissions: read-all

jobs:
build-linux-openssl:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows]
tls: [schannel, openssl]
shared: [on, off]
exclude:
- os: ubuntu
tls: schannel
permissions:
contents: read
name: Build Linux (OpenSSL)
runs-on: ubuntu-latest
name: Build
runs-on: ${{ matrix.os }}-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@9b0655f430fba8c7001d4e38f8d4306db5c6e0ab
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
with:
submodules: 'recursive'
- name: Generate
run: mkdir build && cd build && cmake -G 'Unix Makefiles' ..
- name: Build
run: cd build && cmake --build .
- name: Upload
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
with:
name: bin-linux-openssl
path: |
build/**/*.so
build/**/quicreach
- name: Install
run: cd build && sudo cmake --install . --config Debug
- name: quicreach outlook-evergreen.office.com
run: /usr/local/lib/quicreach outlook-evergreen.office.com
- name: quicreach www.cloudflare.com
run: /usr/local/lib/quicreach www.cloudflare.com
- name: quicreach www.google.com
run: /usr/local/lib/quicreach www.google.com
build-linux-openssl-static:
permissions:
contents: read
name: Build Linux (OpenSSL) Static
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@9b0655f430fba8c7001d4e38f8d4306db5c6e0ab
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
with:
submodules: 'recursive'
- name: Generate
run: mkdir build && cd build && cmake -G 'Unix Makefiles' -DQUIC_BUILD_SHARED=off ..
- name: Build
run: cd build && cmake --build .
- name: Upload
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
with:
name: bin-linux-openssl-static
path: |
build/**/quicreach
- name: Install
run: cd build && sudo cmake --install . --config Debug
- name: quicreach outlook-evergreen.office.com
run: /usr/local/lib/quicreach outlook-evergreen.office.com
- name: quicreach www.cloudflare.com
run: /usr/local/lib/quicreach www.cloudflare.com
- name: quicreach www.google.com
run: /usr/local/lib/quicreach www.google.com
build-windows-openssl:
permissions:
contents: read
name: Build Windows (OpenSSL)
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
with:
submodules: 'recursive'
- name: Install Perl
uses: shogo82148/actions-setup-perl@20a7fcafc28850ff808cc2fa81e688fca4b3b47c
with:
perl-version: '5.34'
- name: Install NASM
uses: ilammy/setup-nasm@10788e307d96af7013172d66126322c70b22efb9
- name: Generate
run: mkdir build && cd build && cmake -G 'Visual Studio 17 2022' -A x64 -DQUIC_TLS=openssl ..
- name: Build
run: cd build && cmake --build .
- name: Upload
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
with:
name: bin-windows-openssl
path: |
build/**/*.dll
build/**/quicreach.exe
- name: Install
run: cd build && cmake --install . --config Debug
- name: quicreach outlook.office.com
run: |
& 'C:/Program Files/quicreach/lib/quicreach' outlook-evergreen.office.com
- name: quicreach www.cloudflare.com
run: |
& 'C:/Program Files/quicreach/lib/quicreach' www.cloudflare.com
- name: quicreach www.google.com
run: |
& 'C:/Program Files/quicreach/lib/quicreach' www.google.com
build-windows-openssl-static:
permissions:
contents: read
name: Build Windows (OpenSSL) Static
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
with:
submodules: 'recursive'
- name: Install Perl
if: runner.os == 'Windows'
uses: shogo82148/actions-setup-perl@20a7fcafc28850ff808cc2fa81e688fca4b3b47c
with:
perl-version: '5.34'
- name: Install NASM
if: runner.os == 'Windows'
uses: ilammy/setup-nasm@10788e307d96af7013172d66126322c70b22efb9
- name: Generate
run: mkdir build && cd build && cmake -G 'Visual Studio 17 2022' -A x64 -DQUIC_BUILD_SHARED=off -DQUIC_TLS=openssl ..
- name: Build
run: cd build && cmake --build .
- name: Upload
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
with:
name: bin-windows-openssl
path: |
build/**/quicreach.exe
- name: Install
run: cd build && cmake --install . --config Debug
- name: quicreach outlook.office.com
- name: Build (Linux)
if: runner.os == 'Linux'
run: |
& 'C:/Program Files/quicreach/lib/quicreach' outlook-evergreen.office.com
- name: quicreach www.cloudflare.com
mkdir build && cd build
cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=RelWithDebInfo -DQUIC_TLS=${{ matrix.tls }} -DQUIC_BUILD_SHARED=${{ matrix.shared }} ..
cmake --build .
sudo cmake --install . --config Release
- name: Build (Windows)
if: runner.os == 'Windows'
run: |
& 'C:/Program Files/quicreach/lib/quicreach' www.cloudflare.com
- name: quicreach www.google.com
run: |
& 'C:/Program Files/quicreach/lib/quicreach' www.google.com
build-windows-schannel:
permissions:
contents: read
name: Build Windows (Schannel)
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
with:
submodules: 'recursive'
- name: Generate
run: mkdir build && cd build && cmake -G 'Visual Studio 17 2022' -A x64 ..
- name: Build
run: cd build && cmake --build .
mkdir build && cd build
cmake -G 'Visual Studio 17 2022' -A x64 -DQUIC_TLS=${{ matrix.tls }} -DQUIC_BUILD_SHARED=${{ matrix.shared }} ..
cmake --build . --config Release
cmake --install . --config Release
- name: Upload
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
with:
name: bin-windows-schannel
name: bin-${{ matrix.os }}-${{ matrix.tls }}-shared_${{ matrix.shared }}
path: |
build/**/*.so
build/**/*.dll
build/**/quicreach
build/**/quicreach.exe
- name: Install
run: cd build && cmake --install . --config Debug
- name: quicreach outlook.office.com
run: |
& 'C:/Program Files/quicreach/lib/quicreach' outlook-evergreen.office.com
- name: quicreach www.cloudflare.com
run: |
& 'C:/Program Files/quicreach/lib/quicreach' www.cloudflare.com
- name: quicreach www.google.com
run: |
& 'C:/Program Files/quicreach/lib/quicreach' www.google.com
build-windows-schannel-static:
permissions:
contents: read
name: Build Windows (Schannel) Static
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
with:
submodules: 'recursive'
- name: Generate
run: mkdir build && cd build && cmake -G 'Visual Studio 17 2022' -A x64 -DQUIC_BUILD_SHARED=off ..
- name: Build
run: cd build && cmake --build .
- name: Upload
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
with:
name: bin-windows-schannel
path: |
build/**/quicreach.exe
- name: Install
run: cd build && cmake --install . --config Debug
- name: quicreach outlook.office.com
run: |
& 'C:/Program Files/quicreach/lib/quicreach' outlook-evergreen.office.com
- name: quicreach www.cloudflare.com
- name: Test (Linux)
if: runner.os == 'Linux'
run: /usr/local/lib/quicreach outlook-evergreen.office.com,www.cloudflare.com,www.google.com --req-all --stats
- name: Test (Windows)
if: runner.os == 'Windows'
run: |
& 'C:/Program Files/quicreach/lib/quicreach' www.cloudflare.com
- name: quicreach www.google.com
run: |
& 'C:/Program Files/quicreach/lib/quicreach' www.google.com
& 'C:/Program Files/quicreach/lib/quicreach' outlook-evergreen.office.com,www.cloudflare.com,www.google.com --req-all --stats
6 changes: 5 additions & 1 deletion src/quicreach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const MsQuicApi* MsQuic;

struct ReachConfig {
bool PrintStatistics {false};
bool RequireAll {false};
std::vector<const char*> HostNames;
uint16_t Port {443};
MsQuicAlpn Alpn {"h3"};
Expand All @@ -42,6 +43,7 @@ bool ParseConfig(int argc, char **argv, ReachConfig& Config) {
" -a, --alpn The ALPN to use for the handshake (def=h3)\n"
" -h, --help Prints this help text\n"
" -p, --port <port> The default UDP port to use\n"
" -r, --req-all Require all hostnames to suceed\n"
" -s, --stats Print connection statistics\n"
" -u, --unsecure Allows unsecure connections\n"
);
Expand Down Expand Up @@ -74,6 +76,8 @@ bool ParseConfig(int argc, char **argv, ReachConfig& Config) {
Config.Port = (uint16_t)atoi(argv[i]);
} else if (!strcmp(argv[i], "--stats") || !strcmp(argv[i], "-s")) {
Config.PrintStatistics = true;
} else if (!strcmp(argv[i], "--req-all") || !strcmp(argv[i], "-r")) {
Config.RequireAll = true;
} else if (!strcmp(argv[i], "--unsecure") || !strcmp(argv[i], "-u")) {
Config.CredFlags |= QUIC_CREDENTIAL_FLAG_NO_CERTIFICATE_VALIDATION;
}
Expand Down Expand Up @@ -154,7 +158,7 @@ bool TestReachability(const ReachConfig& Config) {

if (Config.PrintStatistics && ReachableCount > 1)
printf("\n%u domains reachable\n", ReachableCount);
return ReachableCount != 0;
return Config.RequireAll ? ((size_t)ReachableCount == Config.HostNames.size()) : (ReachableCount != 0);
}

int QUIC_CALL main(int argc, char **argv) {
Expand Down

0 comments on commit 65706e4

Please sign in to comment.