From 6dbbc83468b8e55ccdad367fda956569cb897db0 Mon Sep 17 00:00:00 2001 From: Jamil Bou Kheir Date: Sun, 8 Nov 2020 23:35:28 -0600 Subject: [PATCH] Run functional tests on pushes --- .github/workflows/ci.yml | 9 +++++---- config/releases.exs | 19 +++++++++---------- mix.exs | 2 +- mix.lock | 2 ++ pkg/debian/DEBIAN/postinst | 21 ++++++++++----------- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45e484736..56e5f003f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,6 @@ jobs: build: needs: unit-integration-test runs-on: ubuntu-18.04 - if: github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/') steps: - uses: actions/checkout@v2 - name: Build packages @@ -62,7 +61,6 @@ jobs: if [[ -z "$tag_name" ]] || [[ "$ref" = "refs/heads/master" ]]; then echo "::set-output name=version::${sha}" else - echo "::set-output name=version::${tag_name}" fi - name: Rename Built Artifacts run: | @@ -93,7 +91,7 @@ jobs: sudo dpkg -i fireguard*.deb # Wait for app to start - sleep 5 + sleep 3 # Ensure it's running echo "FireGuard status:" @@ -116,6 +114,9 @@ jobs: 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 @@ -123,6 +124,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./fireguard_${{ steps.tag_name.outputs.tag_name }}-1_amd64.deb + asset_path: ./fireguard_${{ github.sha }}-1_amd64.deb asset_name: fireguard_amd64.deb asset_content_type: application/vnd.debian.binary-package diff --git a/config/releases.exs b/config/releases.exs index b606d8561..86862d68b 100644 --- a/config/releases.exs +++ b/config/releases.exs @@ -4,39 +4,38 @@ # remember to add this file to your .gitignore. import Config -config_file_path = "/opt/fireguard/config.json" -json_data = File.read!(config_file_path) -json_config = Jason.decode!(json_data) +config_file_path = "/opt/fireguard/config.yaml" +yaml_config = YamlElixir.read_from_file!(config_file_path) database_url = - System.get_env("DATABASE_URL") || json_config["database_url"] || + System.get_env("DATABASE_URL") || yaml_config["database_url"] || raise """ config option database_url or environment variable DATABASE_URL is missing. For example: ecto://USER:PASS@HOST/DATABASE """ secret_key_base = - System.get_env("SECRET_KEY_BASE") || json_config["secret_key_base"] || + System.get_env("SECRET_KEY_BASE") || yaml_config["secret_key_base"] || raise """ config option secret_key_base or environment variable SECRET_KEY_BASE is missing. """ live_view_signing_salt = - System.get_env("LIVE_VIEW_SIGNING_SALT") || json_config["live_view_signing_salt"] || + System.get_env("LIVE_VIEW_SIGNING_SALT") || yaml_config["live_view_signing_salt"] || raise """ config option live_view_signing_salt or environment variable LIVE_VIEW_SIGNING_SALT is missing. """ -pool_size = json_config["pool_size"] || String.to_integer(System.get_env("POOL_SIZE") || "10") +pool_size = yaml_config["pool_size"] || String.to_integer(System.get_env("POOL_SIZE") || "10") listen_port = - json_config["listen_port"] || String.to_integer(System.get_env("LISTEN_PORT") || "4000") + yaml_config["listen_port"] || String.to_integer(System.get_env("LISTEN_PORT") || "4000") -listen_host = json_config["listen_host"] || System.get_env("LISTEN_HOST") || "localhost" +listen_host = yaml_config["listen_host"] || System.get_env("LISTEN_HOST") || "localhost" config :fg_vpn, - pubkey: json_config["pubkey"] + pubkey: yaml_config["pubkey"] config :fg_http, FgHttp.Repo, # ssl: true, diff --git a/mix.exs b/mix.exs index 1a56dc26d..1270327ef 100644 --- a/mix.exs +++ b/mix.exs @@ -42,7 +42,7 @@ defmodule FireguardUmbrella.MixProject do [ {:excoveralls, "~> 0.13", only: :test}, {:mix_test_watch, "~> 1.0", only: :dev, runtime: false}, - {:jason, "~> 1.0"} + {:yaml_elixir, "~> 2.5.0"} ] end end diff --git a/mix.lock b/mix.lock index 5abc0ac9f..ee784e424 100644 --- a/mix.lock +++ b/mix.lock @@ -45,4 +45,6 @@ "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.5.0", "8516502659002cec19e244ebd90d312183064be95025a319a6c7e89f4bccd65b", [:rebar3], [], "hexpm", "d48d002e15f5cc105a696cf2f1bbb3fc72b4b770a184d8420c8db20da2674b38"}, + "yamerl": {:hex, :yamerl, "0.8.0", "8214cfe16bbabe5d1d6c14a14aea11c784b9a21903dd6a7c74f8ce180adae5c7", [:rebar3], [], "hexpm", "010634477bf9c208a0767dcca89116c2442cf0b5e87f9c870f85cd1c3e0c2aab"}, + "yaml_elixir": {:hex, :yaml_elixir, "2.5.0", "45de762be6d75fa5a8b5f44ddff8c30f64c26526eab5b1d72e36d616007b7796", [:mix], [{:yamerl, "~> 0.7", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "80fe4e43f05582f2a90f2dcd73fc6171fbd65f2e6836f71fe4ce2154ef358c36"}, } diff --git a/pkg/debian/DEBIAN/postinst b/pkg/debian/DEBIAN/postinst index f61c0b3ff..ff082c6a7 100755 --- a/pkg/debian/DEBIAN/postinst +++ b/pkg/debian/DEBIAN/postinst @@ -31,18 +31,17 @@ privkey=$(wg genkey) pubkey=$(echo ${privkey} | wg pubkey) # Write FireGuard config file -touch /opt/fireguard/config.yml +touch /opt/fireguard/config.yaml chown -R fireguard:root /opt/fireguard -chmod 0600 /opt/fireguard/config.yml -cat <> /opt/fireguard/config.json -{ - "live_view_signing_salt": "${live_view_signing_salt}", - "secret_key_base": "${secret_key_base}", - "database_url": "ecto://${db_user}:${db_password}@localhost/fireguard", - "pubkey": "${pubkey}", - "listen_port": 4000, - "listen_host": "localhost" -} +chmod 0600 /opt/fireguard/config.yaml +cat <> /opt/fireguard/config.yaml +--- +live_view_signing_salt: "${live_view_signing_salt}", +secret_key_base: "${secret_key_base}", +database_url: "ecto://${db_user}:${db_password}@localhost/fireguard", +pubkey: "${pubkey}", +listen_port: 4000, +listen_host: localhost EOT # Grab default route interface