Skip to content

Commit

Permalink
add /test command
Browse files Browse the repository at this point in the history
  • Loading branch information
palexster committed Aug 4, 2021
1 parent edd9e37 commit eb11cbd
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 65 deletions.
64 changes: 0 additions & 64 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,6 @@ jobs:
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
e2e-test-trigger:
runs-on: ubuntu-latest
needs: [build, configure]
if: needs.configure.outputs.ok-to-continue == 'true' && github.event.pull_request.draft == false
steps:
- name: Notify Event to E2E Tests
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.CI_TOKEN }}
repository: liqotech/liqops
event-type: "dev-event"
client-payload: |
{
"master": "${{ needs.configure.outputs.master }}",
"commit": "${{ needs.configure.outputs.commit_ref }}",
"repo-name": "${{ needs.configure.outputs.repo-name }}"
}
docs-pipeline-trigger:
runs-on: ubuntu-latest
needs: configure
Expand Down Expand Up @@ -268,51 +249,6 @@ jobs:
"version": "${{ needs.configure.outputs.commit_ref }}"
}
test:
name: Launch Test
runs-on: ubuntu-20.04
needs: [configure, build]
if: needs.configure.outputs.ok-to-continue == 'true' && github.event.pull_request.draft == false
steps:

- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: "${{ needs.configure.outputs.commit_ref }}"
repository: "${{ needs.configure.outputs.repo-name }}"
persist-credentials: false

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Fetch External CRDs
run: make fetch-external-crds

- name: Launch Test (Docker Container)
uses: addnab/docker-run-action@v3
with:
options: |
--mount type=bind,src=${{ github.workspace }},dst=/go/src/liqotech/liqo
--workdir /go/src/liqotech/liqo
--privileged=true
image: liqo/liqo-test${{ needs.configure.outputs.repo-suffix }}:${{ needs.configure.outputs.commit_ref }}
run: |
go-acc ./... --ignore liqo/test/e2e
- name: Send coverage
uses: shogo82148/actions-goveralls@v1.4.3
with:
path-to-profile: coverage.txt

wait-approve:
name: Wait for the ok-to-test label to test pr on fork
runs-on: ubuntu-20.04
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/slash-commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ jobs:
{
"command": "ok-to-test",
"permission": "write"
}
},
{
"command": "test",
"permission": "write"
},
]
118 changes: 118 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Test the current PR
on:
repository_dispatch:
types:
- test-command

jobs:
configure:
name: Preliminary configuration
runs-on: ubuntu-latest
outputs:
commit_ref: ${{ steps.configure.outputs.commit_ref }}
repo-suffix: ${{ steps.configure.outputs.repo-suffix }}
ok-to-continue: ${{ steps.configure.outputs.ok-to-continue }}
master: ${{ steps.configure.outputs.master }}
repo-name: ${{ steps.configure.outputs.repo-name }}
architectures: ${{ steps.configure.outputs.architectures }}
steps:
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
if: startsWith(github.ref, 'refs/tags/v')
- name: Configure
id: configure
run: |
# The ref of the commit to checkout (do not use the merge commit if pull request)
if [ "${{ github.event_name }}" == "repository_dispatch" ]; then
echo "::set-output name=master::false"
echo "::set-output name=architectures::linux/amd64"
echo "::set-output name=commit_ref::${{ github.event.pull_request.head.sha }}"
elif [ "${{ steps.get_version.outputs.VERSION }}" != "" ]; then
echo "::set-output name=master::false"
echo "::set-output name=architectures::linux/amd64,linux/arm64"
echo "::set-output name=commit_ref::${{ steps.get_version.outputs.VERSION }}"
else
echo "::set-output name=master::true"
echo "::set-output name=architectures::linux/amd64,linux/arm64"
echo "::set-output name=commit_ref::${{ github.sha }}"
fi
# The suffix to append to the repository name if not triggered by a push to master
[[ "${{ steps.get_version.outputs.VERSION }}" == "" ]] && \
echo "::set-output name=repo-suffix::-ci" ||
echo "::set-output name=repo-suffix::"
if [ "${{ github.event_name }}" != "repository_dispatch" ]; then
echo "::set-output name=ok-to-continue::true"
echo "::set-output name=repo-name::${{ github.repository }}"
elif [ "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]; then
echo "::set-output name=ok-to-continue::true"
echo "::set-output name=repo-name::${{ github.repository }}"
elif [ "${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }}" == "true" ]; then
echo "::set-output name=ok-to-continue::true"
echo "::set-output name=repo-name::${{ github.event.pull_request.head.repo.full_name }}"
else
echo "::set-output name=ok-to-continue::false"
echo "::set-output name=repo-name::${{ github.event.pull_request.head.repo.full_name }}"
fi
e2e-test-trigger:
runs-on: ubuntu-latest
steps:
- name: Notify Event to E2E Tests
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.CI_TOKEN }}
repository: liqotech/liqops
event-type: "dev-event"
client-payload: |
{
"master": "false",
"commit": "${{ github.event.client_payload.pull_request.head.ref }}",
"repo-name": "${{ github.event.client_payload.pull_request.head.repo.full_name }}"
}
test:
name: Launch Test
runs-on: ubuntu-20.04
steps:

- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: "${{ needs.configure.outputs.commit_ref }}"
repository: "${{ needs.configure.outputs.repo-name }}"
persist-credentials: false

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Fetch External CRDs
run: make fetch-external-crds

- name: Launch Test (Docker Container)
uses: addnab/docker-run-action@v3
with:
options: |
--mount type=bind,src=${{ github.workspace }},dst=/go/src/liqotech/liqo
--workdir /go/src/liqotech/liqo
--privileged=true
image: liqo/liqo-test${{ needs.configure.outputs.repo-suffix }}:${{ needs.configure.outputs.commit_ref }}
run: |
go-acc ./... --ignore liqo/test/e2e
- name: Send coverage
uses: shogo82148/actions-goveralls@v1.4.3
with:
path-to-profile: coverage.txt

0 comments on commit eb11cbd

Please sign in to comment.