Skip to content

Commit 1fcbeef

Browse files
add build workflow
1 parent af28638 commit 1fcbeef

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.github/workflows/test-build.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Test Build Process
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
name: Run Tests
11+
services:
12+
db:
13+
image: postgres:14
14+
env:
15+
POSTGRES_USER: postgres
16+
POSTGRES_PASSWORD: postgres
17+
POSTGRES_DB: postgres
18+
ports: ['5432:5432']
19+
options: >-
20+
--health-cmd pg_isready
21+
--health-interval 10s
22+
--health-timeout 5s
23+
--health-retries 5
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: actions/[email protected]
27+
with:
28+
elixir-version: 1.14.2
29+
otp-version: 24.1
30+
- name: Cache dependencies
31+
uses: actions/cache@v2
32+
with:
33+
path: deps
34+
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-mix-
37+
- name: Install Dependencies
38+
run: mix deps.get
39+
- name: Start Hasura GraphQL Engine
40+
env:
41+
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
42+
HASURA_GRAPHQL_ENABLE_CONSOLE: "false"
43+
HASURA_GRAPHQL_DEV_MODE: "true"
44+
HASURA_GRAPHQL_ADMIN_SECRET: helloworld
45+
HASURA_GRAPHQL_UNAUTHORIZED_ROLE: visitor
46+
HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES: "true"
47+
run: |
48+
docker run -d --name graphql-engine --network host \
49+
-e HASURA_GRAPHQL_METADATA_DATABASE_URL=${{ env.HASURA_GRAPHQL_METADATA_DATABASE_URL }} \
50+
-e HASURA_GRAPHQL_ENABLE_CONSOLE=${{ env.HASURA_GRAPHQL_ENABLE_CONSOLE }} \
51+
-e HASURA_GRAPHQL_DEV_MODE=${{ env.HASURA_GRAPHQL_DEV_MODE }} \
52+
-e HASURA_GRAPHQL_ADMIN_SECRET=${{ env.HASURA_GRAPHQL_ADMIN_SECRET }} \
53+
-e HASURA_GRAPHQL_UNAUTHORIZED_ROLE=${{ env.HASURA_GRAPHQL_UNAUTHORIZED_ROLE }} \
54+
-e HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES=${{ env.HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES }} \
55+
hasura/graphql-engine:v2.40.0
56+
- name: Run Tests
57+
run: mix test
58+
59+
build:
60+
runs-on: ubuntu-latest
61+
needs: test
62+
steps:
63+
- uses: actions/checkout@v2
64+
- name: Set up Docker Buildx
65+
uses: docker/setup-buildx-action@v1
66+
- name: Log in to GitHub Container Registry
67+
uses: docker/login-action@v1
68+
with:
69+
registry: ghcr.io
70+
username: ${{ github.actor }}
71+
password: ${{ secrets.GITHUB_TOKEN }}
72+
- name: Build Docker Image
73+
uses: docker/build-push-action@v2
74+
with:
75+
context: .
76+
push: false
77+
tags: ghcr.io/${{ github.repository_owner }}/my_phoenix_app:test-${{ github.sha }}

0 commit comments

Comments
 (0)