Skip to content

Commit

Permalink
Include changes to init image in tests (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
ypc-faros committed May 6, 2022
1 parent 9a8b1ab commit 2e4e98d
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 55 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: PR

on:
pull_request:
branches:
- main
paths-ignore:
- '**.md'

jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Check out
uses: actions/checkout@v2

- name: Check for style & bugs
uses: ludeeus/action-shellcheck@1.1.0
with:
ignore: wait-for
env:
SHELLCHECK_OPTS: -s bash -e SC2162 -e SC2153

- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: 17

- name: Build
run: npm ci --unsafe-perm
working-directory: init

- name: Run unit tests
run: npm run test:unit -- --coverage
working-directory: init

# In order to optimize for speed, we use the latest init image.
- name: Start services
run: FAROS_INIT_IMAGE=farosai/faros-ce-init:latest docker-compose up --quiet-pull -d

- name: Show logs
run: docker-compose logs --tail all

- name: Show services
run: docker-compose ps -a

- name: Wait for init to complete
run: docker wait faros-community-edition_faros-init_1

- name: Get destination id & Hasura Admin Secret
run: |
echo "DESTINATION_ID=$(cat ${{ github.workspace }}/init/resources/airbyte/workspace/airbyte_config/DESTINATION_CONNECTION.yaml | yq '.[0].destinationId')" >> "$GITHUB_ENV"
echo $(cat .env | grep "^HASURA_GRAPHQL_ADMIN_SECRET") >> "$GITHUB_ENV"
- name: Run integration tests
run: npm run test:integration -- --coverage
working-directory: init

- name: Stop services
run: docker-compose down


86 changes: 31 additions & 55 deletions .github/workflows/ci-cd.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,59 @@
name: CI/CD
name: Release

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- '**.md'

jobs:
test:
name: Test
publish-docker:
name: Publish Docker
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 20

steps:
- name: Check out
uses: actions/checkout@v2

- name: Check for style & bugs
uses: ludeeus/action-shellcheck@1.1.0
with:
ignore: wait-for
env:
SHELLCHECK_OPTS: -s bash -e SC2162 -e SC2153

- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 17

- name: Build
run: npm ci --unsafe-perm
working-directory: init

- name: Run unit tests
run: npm run test:unit -- --coverage
working-directory: init
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
farosai/faros-ce-init
flavor: |
latest=auto
tags: |
type=sha,format=long,prefix=
type=raw,value=latest,enable=true
- name: Docker Compose version
run: docker-compose version --short
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build Docker image
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Start services
run: docker-compose up --quiet-pull -d
run: FAROS_INIT_IMAGE=farosai/faros-ce-init:${{ github.sha }} docker-compose up --quiet-pull -d

- name: Show logs
run: docker-compose logs --tail all
Expand All @@ -61,55 +68,24 @@ jobs:
run: |
echo "DESTINATION_ID=$(cat ${{ github.workspace }}/init/resources/airbyte/workspace/airbyte_config/DESTINATION_CONNECTION.yaml | yq '.[0].destinationId')" >> "$GITHUB_ENV"
echo $(cat .env | grep "^HASURA_GRAPHQL_ADMIN_SECRET") >> "$GITHUB_ENV"
- name: Run integration tests
run: npm run test:integration -- --coverage
working-directory: init

- name: Stop services
run: docker-compose down

publish-docker:
name: Publish Docker
runs-on: ubuntu-latest
timeout-minutes: 15
needs: test
if: github.ref == 'refs/heads/main' # Skip PRs

steps:
- name: Check out
uses: actions/checkout@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
farosai/faros-ce-init
flavor: |
latest=auto
tags: |
type=sha,format=long,prefix=
type=raw,value=latest,enable=true
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 2e4e98d

Please sign in to comment.