Skip to content

Commit

Permalink
Add test command
Browse files Browse the repository at this point in the history
  • Loading branch information
Akrog committed Apr 24, 2020
1 parent b5da5ba commit 3cd3911
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-command.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# TODO: Don't build if the PR is not based on master's HEAD
# TODO: Only build the container if specific directories/files have changed, unless forced: https://coderwall.com/p/lz0uva/find-all-files-modified-between-commits-in-git
name: build-command
on:
repository_dispatch:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/command-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,10 @@ jobs:
"command": "build",
"permission": "write",
"issue_type": "pull-request"
},
{
"command": "test",
"permission": "write",
"issue_type": "pull-request"
}
]
88 changes: 88 additions & 0 deletions .github/workflows/test-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# TODO: Don't build if the PR is not based on master's HEAD
# TODO: Only build the container if specific directories/files have changed, unless forced: https://coderwall.com/p/lz0uva/find-all-files-modified-between-commits-in-git
name: test-command
on:
repository_dispatch:
types: [test-command]

jobs:

build:
env:
AUTHORIZED: ${{ github.actor != github.event.client_payload.pull_request.base.repo.owner.login }}
SOURCE_BRANCH: master
DOCKER_REPO: embercsi/ci_images
IMAGE_TAG: ${{ format('{0}-{1}', github.event.client_payload.pull_request.number, github.event.client_payload.pull_request.head.sha) }}
DETAILS_URL: ${{ format('https://github.com/{0}/actions/runs/{1}', github.repository, github.run_id) }}
JOB_NAME: internal/build-pr-images
TAGS_MISSING: false

# In the future we may want to return embercsi/ember-csi:{master,latest}
outputs:
image_base_name: ${{ format('{0}:{1}-', env.DOCKER_REPO, env.IMAGE_TAG) }}

runs-on: ubuntu-latest
steps:
# Checkout the pull request branch from the repository
- uses: actions/checkout@v2
if: env.AUTHORIZED == 'true'
with:
token: ${{ secrets.TOKEN }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}

- name: Notify in_progress
run: |
curl -X POST -H "Authorization: token ${{ secrets.TOKEN }}" -H "Content-Type: application/json" -d '{"context": "${{ env.JOB_NAME }}","state": "pending","target_url": "${{ env.DETAILS_URL }}"}' "https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.client_payload.pull_request.head.sha }}"
- name: Check if images exist
if: env.AUTHORIZED == 'true'
run: |
for i in 7 8; do
tag_info=`curl -fL --silent ${{ format('https://hub.docker.com/v2/repositories/{0}/tags/{1}', env.DOCKER_REPO, env.IMAGE_TAG) }}-$i`
if [[ ! $tag_info == *'"name"'* ]]; then
echo "::set-env name=TAGS_MISSING::true"
break
fi
done
- name: Build images
if: env.AUTHORIZED == 'true' && env.TAGS_MISSING == 'true'
run: |
echo 'Start'
echo "::add-mask::${{ secrets.DOCKER_PASSWORD }}"
EMBER_VERSION=$IMAGE_TAG hooks/build
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
docker tag $DOCKER_REPO:master7 $DOCKER_REPO:${IMAGE_TAG}-7
docker tag $DOCKER_REPO:master8 $DOCKER_REPO:${IMAGE_TAG}-8
docker push $DOCKER_REPO:${IMAGE_TAG}-7
docker push $DOCKER_REPO:${IMAGE_TAG}-8
echo 'Done'
- name: Get result status
if: always()
run: |
status=`echo "${{ job.status }}" | tr '[:upper:]' '[:lower:]'`
if [[ "$status" == "cancelled" ]]; then
echo "::set-env name=JOB_RESULT::error"
else
echo "::set-env name=JOB_RESULT::$status"
fi
- name: Notify result status
if: always()
run: |
curl -X POST -H "Authorization: token ${{ secrets.TOKEN }}" -H "Content-Type: application/json" -d '{"context": "${{ env.JOB_NAME }}","state": "${{ env.JOB_RESULT }}","target_url": "${{ env.DETAILS_URL }}"}' "https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.client_payload.pull_request.head.sha }}"
testing:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
centos: [7, 8]
steps:
- name: Testing
run: |
pwd
echo Running with backend ${{ matrix.backend }} on a Centos ${{ matrix.centos }} VM
echo Job is ${{ job }}

0 comments on commit 3cd3911

Please sign in to comment.