From f16efa65b75fefa18876fbee55beb3f90774b7c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Pa=C3=9F?= <22845248+mpass99@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:13:41 +0100 Subject: [PATCH] Extract e2e test environment variables into file. --- .github/workflows/ci.yml | 18 ++++++------------ .github/workflows/resources/.env | 7 +++++++ .../resources/poseidon-minimal.service | 3 +-- 3 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/resources/.env diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2af74a..8c75738 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,16 +125,12 @@ jobs: runs-on: ubuntu-latest needs: [ compile, test ] env: - POSEIDON_AWS_ENABLED: false POSEIDON_AWS_ENDPOINT: ${{ secrets.POSEIDON_AWS_ENDPOINT }} - POSEIDON_AWS_FUNCTIONS: "" - POSEIDON_LOGGER_FORMATTER: "JSONFormatter" - POSEIDON_LOG_FILE: "../../poseidon.log" - POSEIDON_NOMAD_DISABLEFORCEPULL: true - GOCOVERDIR: coverage steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Write secrets to environment file + run: cat ./.github/workflows/resources/.env | envsubst > ./.env - name: Set up Go uses: actions/setup-go@v5 with: @@ -203,6 +199,7 @@ jobs: run: make e2e-test-docker-image - name: Run e2e tests run: | + export $(cat ./.env | xargs) sudo ./nomad agent -dev -log-level=WARN -config e2e-config.hcl & until curl -s --fail http://localhost:4646/v1/agent/health ; do sleep 1; done chmod +x ./poseidon @@ -210,16 +207,15 @@ jobs: ./poseidon | tee poseidon.log & until curl -s --fail http://localhost:7200/api/v1/health ; do sleep 1; done make e2e-test - - name: Write Environment Variables to file - run: | - echo "${{ vars }}" if: ${{ success() || failure() }} - name: Setup Poseidon Socket run: | + export $(cat ./.env | xargs) killall poseidon mkdir -p ~/.config/systemd/user cp ./.github/workflows/resources/poseidon-minimal.socket ~/.config/systemd/user/poseidon.socket cat ./.github/workflows/resources/poseidon-minimal.service | envsubst > ~/.config/systemd/user/poseidon.service + echo "POSEIDON_SERVER_SYSTEMDSOCKETACTIVATION=TRUE" >> ./.env systemctl --user daemon-reload systemctl --user start poseidon.socket if: ${{ success() || failure() }} @@ -235,9 +231,7 @@ jobs: journalctl --user -xe -u poseidon.service --no-pager if: failure() - name: Stop Poseidon to flush the coverage file - run: | - systemctl --user stop poseidon.service poseidon.socket - ls -lah ${GOCOVERDIR} + run: systemctl --user stop poseidon.service poseidon.socket if: ${{ success() || failure() }} - name: Convert coverage reports run: make convert-run-coverage diff --git a/.github/workflows/resources/.env b/.github/workflows/resources/.env new file mode 100644 index 0000000..47f015f --- /dev/null +++ b/.github/workflows/resources/.env @@ -0,0 +1,7 @@ +POSEIDON_AWS_ENABLED="false" +POSEIDON_AWS_ENDPOINT="${POSEIDON_AWS_ENDPOINT}" +POSEIDON_AWS_FUNCTIONS="" +POSEIDON_LOGGER_FORMATTER="JSONFormatter" +POSEIDON_LOG_FILE="${GITHUB_WORKSPACE}/poseidon.log" +POSEIDON_NOMAD_DISABLEFORCEPULL="true" +GOCOVERDIR="${GITHUB_WORKSPACE}/coverage" diff --git a/.github/workflows/resources/poseidon-minimal.service b/.github/workflows/resources/poseidon-minimal.service index 1a1afe6..835e502 100644 --- a/.github/workflows/resources/poseidon-minimal.service +++ b/.github/workflows/resources/poseidon-minimal.service @@ -8,8 +8,7 @@ Requires=poseidon.socket [Service] WorkingDirectory=${GITHUB_WORKSPACE} ExecStart=${GITHUB_WORKSPACE}/poseidon -Environment="POSEIDON_SERVER_SYSTEMDSOCKETACTIVATION=TRUE" -Environment="GOCOVERDIR=${GITHUB_WORKSPACE}/${GOCOVERDIR}" +EnvironmentFile=${GITHUB_WORKSPACE}/.env Restart=always StartLimitBurst=0