mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
156 lines
4.7 KiB
YAML
156 lines
4.7 KiB
YAML
name: CI
|
|
on:
|
|
- push
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
unit-integration-test:
|
|
runs-on: ubuntu-20.04
|
|
env:
|
|
MIX_ENV: test
|
|
POSTGRES_HOST: localhost
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
services:
|
|
postgres:
|
|
image: postgres:13
|
|
ports:
|
|
- 5432:5432
|
|
env:
|
|
POSTGRES_USER: fireguard
|
|
POSTGRES_PASSWORD: postgres
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- name: Install package dependencies
|
|
run: sudo apt-get install net-tools wireguard
|
|
- uses: actions/checkout@v2
|
|
- name: Install Runtimes
|
|
run: |
|
|
wget -O erlang.deb https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_23.2-1~ubuntu~focal_amd64.deb
|
|
wget -O elixir.deb https://packages.erlang-solutions.com/erlang/debian/pool/elixir_1.11.2-1~ubuntu~focal_all.deb
|
|
sudo dpkg -i erlang.deb
|
|
sudo dpkg -i elixir.deb
|
|
- name: Install Dependencies
|
|
run: |
|
|
mix local.hex --force && mix local.rebar --force
|
|
mix deps.get --only test
|
|
- name: Setup Database
|
|
run: |
|
|
mix ecto.create
|
|
mix ecto.migrate
|
|
- name: Run Tests and Upload Coverage Report
|
|
run: mix coveralls.github --umbrella
|
|
|
|
build:
|
|
needs: unit-integration-test
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-20.04]
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Install runtimes
|
|
run: |
|
|
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
|
|
sudo apt install nodejs
|
|
matrix_os=${{ matrix.os }}
|
|
case $matrix_os in
|
|
ubuntu-18.04)
|
|
os_name="ubuntu~bionic"
|
|
;;
|
|
ubuntu-20.04)
|
|
os_name="ubuntu~focal"
|
|
;;
|
|
esac
|
|
|
|
wget -O erlang.deb https://packages.erlang-solutions.com/erlang/debian/pool/esl-erlang_23.1-1~$os_name_amd64.deb
|
|
wget -O elixir.deb https://packages.erlang-solutions.com/erlang/debian/pool/elixir_1.11.2-1~$os_name_all.deb
|
|
sudo dpkg -i erlang.deb
|
|
sudo dpkg -i elixir.deb
|
|
- name: Build release
|
|
env:
|
|
MIX_ENV: prod
|
|
run: |
|
|
scripts/build_release.sh
|
|
scripts/build_deb.sh
|
|
- name: Rename Built Artifacts
|
|
run: |
|
|
filename="fireguard_${{ github.sha }}-1_amd64.deb"
|
|
mv fireguard_${{ matrix.os }}_amd64.deb ./${filename}
|
|
- uses: actions/upload-artifact@v2
|
|
with:
|
|
name: fireguard-deb
|
|
path: "fireguard*.deb"
|
|
|
|
functional-test:
|
|
needs: build
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-20.04]
|
|
steps:
|
|
- uses: actions/download-artifact@v2
|
|
with:
|
|
name: fireguard-deb
|
|
- name: Test Install package
|
|
env:
|
|
DEBIAN_FRONTEND: noninteractive
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y postgresql \
|
|
wireguard iptables net-tools curl ca-certificates
|
|
sudo systemctl start postgresql
|
|
sudo dpkg -i fireguard*.deb
|
|
|
|
echo "Enabling service..."
|
|
sudo systemctl start fireguard
|
|
|
|
# Wait for app to start
|
|
sleep 10
|
|
|
|
echo "Printing service status..."
|
|
sudo journalctl -u fireguard.service
|
|
|
|
echo "Trying to load homepage..."
|
|
curl -i -vvv -k https://$(hostname):8800/
|
|
|
|
echo "Printing SSL debug info"
|
|
openssl s_client -connect $(hostname):8800 -servername $(hostname) -showcerts -prexit
|
|
|
|
publish:
|
|
needs: functional-test
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-20.04]
|
|
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
|
|
steps:
|
|
- 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 }}
|
|
draft: false
|
|
prerelease: true
|
|
- uses: actions/download-artifact@v2
|
|
with:
|
|
name: fireguard-deb
|
|
- name: Upload Release Asset
|
|
id: upload-release-asset
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
asset_path: ./fireguard_${{ github.sha }}-1_${{ matrix.os }}_amd64.deb
|
|
asset_name: fireguard_${{ matrix.os }}_amd64.deb
|
|
asset_content_type: application/vnd.debian.binary-package
|