Skip to content

Commit

Permalink
Merge pull request #152 from conductor-sdk/fix/unit-tests-run-on-build
Browse files Browse the repository at this point in the history
Unit test run on build workflow, fix checkout in integration tests workflow + fail PR if integration tests fail.
  • Loading branch information
jmigueprieto authored Sep 18, 2024
2 parents fa5b7a8 + feca264 commit 3ba7570
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ jobs:
--progress=plain
--target=build
.
- name: Test
run: >
DOCKER_BUILDKIT=1 docker build
--progress=plain
--target=test
.
40 changes: 36 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,52 @@ on:
- completed

jobs:
tests:
integration-tests:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Test
ref: ${{ github.event.workflow_run.head_sha }}
repository: ${{ github.event.workflow_run.repository.full_name }}
- name: Run Integration Tests
id: integration_test
run: >
DOCKER_BUILDKIT=1 docker build
--progress=plain
--build-arg KEY=${{ secrets.KEY }}
--build-arg SECRET=${{ secrets.SECRET }}
--build-arg CONDUCTOR_SERVER_URL=${{ secrets.CONDUCTOR_SERVER_URL }}
--target=test
--target=inttest
.
- name: Set PR Status to Failure
if: ${{ failure() }}
uses: actions/github-script@v6
with:
script: |
const { owner, repo } = context.repo;
const sha = context.payload.workflow_run.head_sha;
await github.rest.repos.createCommitStatus({
owner: owner,
repo: repo,
sha: sha,
state: 'failure',
context: 'Integration Tests',
description: 'Integration tests failed.',
});
- name: Set PR Status to Success
if: ${{ success() }}
uses: actions/github-script@v6
with:
script: |
const { owner, repo } = context.repo;
const sha = context.payload.workflow_run.head_sha;
await github.rest.repos.createCommitStatus({
owner: owner,
repo: repo,
sha: sha,
state: 'success',
context: 'Integration Tests',
description: 'Integration tests succeeded.',
});
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ RUN go build -v ./...

FROM build as test
COPY /test /package/test
RUN go test -v $(go list ./... | grep -v /test/integration_tests)

FROM build as inttest
COPY /test /package/test
ARG KEY
ARG SECRET
ARG CONDUCTOR_SERVER_URL
ENV KEY=${KEY}
ENV SECRET=${SECRET}
ENV CONDUCTOR_SERVER_URL=${CONDUCTOR_SERVER_URL}
RUN go test -v ./...
RUN go test -v ./test/integration_tests/...

0 comments on commit 3ba7570

Please sign in to comment.