-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Migrate CI to Gh actions (#52)
* Initial GH actions commit * small fix * small fix * final * add image build job
- Loading branch information
Meer Sawood
authored
Feb 4, 2021
1 parent
f250ba3
commit 6ee42e5
Showing
7 changed files
with
151 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: CI Build / Push Image | ||
on: | ||
repository_dispatch: | ||
types: [build-image-command] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
REPOSITORY: ${{ github.event.client_payload.github.payload.repository.full_name }} | ||
DEFAULT_TAG: SNAPSHOT-PR-${{ github.event.client_payload.github.payload.issue.number }} | ||
FULL_NAME: fabric8-analytics-github-refresh-cornjob | ||
|
||
|
||
jobs: | ||
Build-push-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: | | ||
git fetch origin +refs/pull/${{ github.event.client_payload.github.payload.issue.number }}/merge | ||
git checkout FETCH_HEAD | ||
- name: Create comment | ||
uses: peter-evans/create-or-update-comment@v1 | ||
with: | ||
edit-mode: replace | ||
comment-id: ${{ github.event.client_payload.github.payload.comment.id }} | ||
body: | | ||
**Edit:** :test_tube: [CI has Started Image Build]( https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) | ||
reactions: eyes | ||
- name: Login to Github Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env. REGISTRY }} | ||
username: ${{ github.event.client_payload.github.actor }} | ||
password: ${{ secrets.CR_PAT }} | ||
- name: Build Image | ||
run: docker build --no-cache -t ${{env.REGISTRY}}/${{env.REPOSITORY}}/${{env.FULL_NAME}}:${{env.DEFAULT_TAG}} -f Dockerfile . | ||
- name: Push Image | ||
run: docker push ${{env.REGISTRY}}/${{env.REPOSITORY}}/${{env.FULL_NAME}}:${{env.DEFAULT_TAG}} | ||
- name: Create success comment | ||
if: success() | ||
uses: peter-evans/create-or-update-comment@v1 | ||
env: | ||
IMAGE_URL: ${{env.REGISTRY}}/${{env.REPOSITORY}}/${{env.FULL_NAME}}:${{env.DEFAULT_TAG}} | ||
with: | ||
edit-mode: replace | ||
comment-id: ${{ github.event.client_payload.github.payload.comment.id }} | ||
body: | | ||
**Edit:** :v: [Image Build Successfull]( https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) @${{github.event.client_payload.github.actor}}, Avaliable at: ```${{ env.IMAGE_URL }}``` | ||
reactions: hooray, heart | ||
- name: Create fail comment | ||
if: failure() | ||
uses: peter-evans/create-or-update-comment@v1 | ||
with: | ||
edit-mode: replace | ||
comment-id: ${{ github.event.client_payload.github.payload.comment.id }} | ||
body: | | ||
**Edit:** :facepalm: [Build and Push Image Failed]( https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) | ||
reactions: confused |
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,67 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
Code-Quality-Checks: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
scripts: | ||
- run-linter | ||
- check-docstyle | ||
- detect-dead-code | ||
- detect-common-errors | ||
- measure-maintainability-index | ||
- measure-cyclomatic-complexity | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.6 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.6' | ||
- name: Install virtualenv | ||
run: pip install -U pip && pip install virtualenv | ||
- name: ${{ matrix.scripts }} | ||
run: bash qa/${{ matrix.scripts }}.sh; | ||
Unit-Tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.6 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.6' | ||
- name: Install virtualenv | ||
run: pip install -U pip && pip install virtualenv | ||
- name: Run Unit Tests | ||
run: bash qa/runtests.sh | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
file: ./coverage.xml | ||
openshift-yaml-validate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install oc | ||
uses: redhat-actions/oc-installer@v1 | ||
with: | ||
version: '4.6' | ||
- name: Run oc process | ||
run: oc process --local -f openshift/template.yaml -o yaml > blueprint.yaml | ||
- name: validate openshift yaml | ||
uses: instrumenta/kubeval-action@master | ||
with: | ||
files: blueprint.yaml | ||
Build-docker-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run Docker Build | ||
run: docker build --no-cache -t tests-image -f Dockerfile . |
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,14 @@ | ||
name: Slash Command Dispatch | ||
on: | ||
issue_comment: | ||
types: [created] | ||
jobs: | ||
slashCommandDispatch: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Slash Command Dispatch | ||
uses: peter-evans/slash-command-dispatch@v2 | ||
with: | ||
token: ${{ secrets.CR_PAT }} | ||
commands: | | ||
build-image |
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
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