Connection Tests - Basic #156
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
name: Connection Tests - Basic | |
on: | |
workflow_dispatch: | |
jobs: | |
connection-tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-24.04 # WARNING: Please note that this is a Beta version. | |
- ubuntu-22.04 | |
- ubuntu-20.04 | |
- macos-14 # An Arm64 Runner. | |
- macos-13 | |
- macos-12 | |
- windows-2022 | |
- windows-2019 | |
runs-on: ${{ matrix.os }} | |
name: "run:${{ matrix.os }}" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 # Checkout the code to run tests | |
- name: Setup Pritunl Profile | |
id: pritunl-connection | |
uses: ./ # Use `nathanielvarona/pritunl-client-github-action@v1` for your GitHub Action workflow. | |
with: | |
profile-file: ${{ secrets.PRITUNL_PROFILE_FILE_BASIC }} | |
# The steps below demonstrate how to verify VPN gateway connectivity, including: | |
# 1. Installing IP Calculator | |
# 2. Pinging the VPN gateway | |
# This is a simple example of how to test VPN gateway connectivity, ensuring a stable and secure connection. | |
- name: Install IP Tooling (IP Calculator) | |
shell: bash | |
run: | | |
# Install IP Calculator | |
# Check the runner OS and install IP Calculator accordingly | |
# Linux: use apt-get | |
# macOS: use brew | |
# Windows: download from URL with retry logic (up to 3 attempts) | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
# Install IP Calculator on Linux | |
sudo apt-get install -qq -o=Dpkg::Use-Pty=0 -y ipcalc | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
# Install IP Calculator on macOS | |
brew install -q ipcalc | |
elif [ "$RUNNER_OS" == "Windows" ]; then | |
# Install IP Calculator on Windows with retry logic | |
for attempt in $(seq 3); do | |
if curl -sSL "https://raw.githubusercontent.com/kjokjo/ipcalc/0.51/ipcalc" \ | |
-o $HOME/bin/ipcalc && chmod +x $HOME/bin/ipcalc; then | |
break | |
else | |
echo "Attempt $attempt failed. Retrying..." && sleep 1 | |
# If all retries fail, exit with an error | |
if [ $attempt -eq 3 ]; then | |
echo "Failed to install ipcalc after 3 attempts." && exit 1 | |
fi | |
fi | |
done | |
fi | |
# Verify IP Calculator installation | |
echo "ipcalc version $(ipcalc --version)" | |
- name: VPN Gateway Reachability Test | |
shell: bash | |
run: | | |
# Set the ping count | |
ping_count_number=5 | |
# Get the profile IP | |
profile_ip=$(pritunl-client list -j | jq ". | sort_by(.name)" | jq ".[0]" | jq -r ".client_address") | |
# Get the VPN gateway IP | |
vpn_gateway="$(ipcalc $profile_ip | awk 'NR==6{print $2}')" | |
# Set the ping flags based on the runner OS | |
ping_flags="$([[ "$RUNNER_OS" == "Windows" ]] && echo "-n $ping_count_number" || echo "-c $ping_count_number")" | |
# Ping the VPN gateway | |
ping $vpn_gateway $ping_flags |