-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
123 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,9 @@ jobs: | |
{ | ||
"command": "ok-to-test", | ||
"permission": "write" | ||
} | ||
}, | ||
{ | ||
"command": "test", | ||
"permission": "write" | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |