Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR] Fix CI API tests failing #314

Merged
merged 29 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7c92688
fix: Trying to fix CI API tests failing. #297
LuchoTurtle Feb 21, 2023
0e3aa36
fix: Sleeping for longer to see if it's enough time to start API test…
LuchoTurtle Feb 21, 2023
7c622c9
fix: Changing hopps CLI version. #297
LuchoTurtle Feb 21, 2023
8b5e4c3
fix: Checking if CI makes outbound calls. #297
LuchoTurtle Feb 22, 2023
69cdac1
fix: Switching order. Deploying app first and testing later. #297
LuchoTurtle Feb 22, 2023
a1ea903
fix: Fix yaml syntax. #297
LuchoTurtle Feb 22, 2023
77d357f
fix: Fixing CI yaml syntax. #297
LuchoTurtle Feb 22, 2023
67be013
fix: Syntax error. #297
LuchoTurtle Feb 22, 2023
ee1457d
fix: Fix yamlf ile. #297
LuchoTurtle Feb 22, 2023
3ea81f6
fix: Refactoring workflows. #297
LuchoTurtle Feb 22, 2023
2bf5614
fix: Renaming branch_ci to PR_ci. #297
LuchoTurtle Feb 22, 2023
ed4f8c3
fix: Checking out on PR_ci.yml file. #297
LuchoTurtle Feb 22, 2023
d7fba55
fix: Using post-request scripts to set env variables for tests runnin…
LuchoTurtle Feb 23, 2023
8a584c8
feat: Adding comments and removing seeds. #297
LuchoTurtle Feb 23, 2023
1548b7f
fix: Making tests run regardless of seeds. Adding new env variables. …
LuchoTurtle Feb 27, 2023
2007d8c
fix: Updating README. #297
LuchoTurtle Feb 27, 2023
1d9c49a
fix: Fixing typos in review app document. #297
LuchoTurtle Feb 27, 2023
7447bfc
revert name main_ci.yml ci.yml https://github.com/dwyl/mvp/pull/314/f…
nelsonic Feb 27, 2023
1a7752c
rename PR_ci.yml to just pr.yml for consistency https://github.com/dw…
nelsonic Feb 27, 2023
82368a2
fix: Changing JSON file to deployed app dynamically. #297
LuchoTurtle Feb 28, 2023
8b5cb57
fix: Fixing warnings in yaml file. #297
LuchoTurtle Feb 28, 2023
b8fca4b
fix: Fixing join operation on yaml file. #297
LuchoTurtle Feb 28, 2023
1d65ecd
fix: Fixing join function in workflow. #297
LuchoTurtle Feb 28, 2023
c8ab185
fix: Fixing JSON var changing. #297
LuchoTurtle Feb 28, 2023
7bf1fad
fix: Trying to change json file. #297
LuchoTurtle Feb 28, 2023
077c2a9
fix: Placing the json field changing to `api_definition` job. #297
LuchoTurtle Feb 28, 2023
f96d854
feat: Adding missing values to fly_dev.json file. #297
LuchoTurtle Feb 28, 2023
476fccb
fix: Re-exporting MVP test suite changes. Review_app not dependant on…
LuchoTurtle Feb 28, 2023
999ee62
fix: Fixing the `build-review-apps.md` with latest changes/ #297
LuchoTurtle Feb 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/PR_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: PR CI

on:
pull_request:
branches: [ main ]
types: [opened, reopened, synchronize, closed]

jobs:

# BUILD AND UNIT TESTING
build:

# Only run when not closed
if: github.event.pull_request.action != 'closed'

name: Build and Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
ports: ['5432:5432']
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
otp: ['25.1.2']
elixir: ['1.14.2']
steps:
- uses: actions/checkout@v2
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Restore deps and _build cache
uses: actions/cache@v3
with:
path: |
deps
_build
key: deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}
- name: Install dependencies
run: mix deps.get
- name: Check code is formatted
run: mix format --check-formatted
- name: Run Tests
run: mix coveralls.json
env:
MIX_ENV: test
AUTH_API_KEY: ${{ secrets.AUTH_API_KEY }}
ENCRYPTION_KEYS: ${{ secrets.ENCRYPTION_KEYS }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1



# DEPLOY THE REVIEW APP
# This will deploy an app to fly.io with the name 'mvp-pr-$PR_NUMBER' (check `review-apps.sh` script).
review_app:

# Only run when it's not a dependabot PR
if: github.event.pull_request.user.login != 'dependabot[bot]'

name: Review App Job
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install flyctl
run: curl -L https://fly.io/install.sh | FLYCTL_INSTALL=/usr/local sh

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: 24.3.4
elixir-version: 1.14.1

- name: Run Review App Script
run: ./.github/scripts/review-apps.sh
env:
ENCRYPTION_KEYS: ${{ secrets. ENCRYPTION_KEYS }}
AUTH_API_KEY: ${{ secrets.FLY_AUTH_API_KEY }}
PR_NUMBER: ${{ github.event.number}}
EVENT_ACTION: ${{ github.event.action }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
FLY_ORG: dwyl-mvp
FLY_REGION: lhr
FLY_POSTGRES_NAME: mvp-db



# API DEFINITION TESTING - https://docs.hoppscotch.io/cli
# NOTE: The tests are executed sequentially in each folder
# but all the sequence of folders are run in reverse order of what's displayed in the GUI.
# We've made use of env variables to make it work. Take this into account if you want to add more requests.
api_definition:

# Only run when not closed
if: github.event.pull_request.action != 'closed'

name: API Definition Tests
runs-on: ubuntu-latest
needs: [review_app]
steps:
- uses: actions/checkout@v2
- name: Install Hoppscotch CLI
run: npm i -g @hoppscotch/[email protected]

- name: Running server and Hoppscotch Tests
run: hopp test -e ./lib/api/fly_dev.json ./lib/api/MVP.json
55 changes: 1 addition & 54 deletions .github/workflows/ci.yml → .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Elixir CI
on:
nelsonic marked this conversation as resolved.
Show resolved Hide resolved
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

Expand Down Expand Up @@ -56,64 +54,13 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1

# API Definition testing
# https://docs.hoppscotch.io/cli
api_definition:
name: API Definition Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
ports: ['5432:5432']
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
otp: ['25.1.2']
elixir: ['1.14.2']
steps:
- uses: actions/checkout@v2
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Restore deps and _build cache
uses: actions/cache@v3
with:
path: |
deps
_build
key: deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}
- name: Install dependencies
run: mix deps.get

- name: Install Hoppscotch CLI
run: npm i -g @hoppscotch/cli

# Setups database and adds seed data for API definition tests
- name: Run mix setup
run: mix ecto.setup
env:
MIX_ENV: dev
AUTH_API_KEY: ${{ secrets.AUTH_API_KEY }}

- name: Running server and Hoppscotch Tests
run: mix phx.server & sleep 5 && hopp test -e ./lib/api/localhost.json ./lib/api/MVP.json

# Continuous Deployment to Fly.io
# https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
deploy:
name: Deploy app
runs-on: ubuntu-latest
needs: [build, api_definition]
needs: [build]
# https://stackoverflow.com/questions/58139406/only-run-job-on-specific-branch-with-github-actions
if: github.ref == 'refs/heads/main'
env:
Expand Down
32 changes: 0 additions & 32 deletions .github/workflows/review-apps.yml

This file was deleted.

Loading