-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 209b8d1
Showing
7 changed files
with
306 additions
and
0 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,18 @@ | ||
name: Test Workflow | ||
on: push | ||
jobs: | ||
first-job: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Run Action | ||
uses: ./ | ||
with: | ||
user: softknife2021 | ||
token: ${{secrets.GH_AUTH_TOKEN}} | ||
repo: actions-play | ||
workflow: pr_build | ||
branch: main | ||
group: smoke | ||
env: test |
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,134 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
#idea | ||
*.iml | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
venv/ | ||
.idea/ |
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,9 @@ | ||
# action will be run in python3 container | ||
FROM python:3 | ||
# copying requirements.txt and install the action dependencies | ||
COPY requirements.txt /requirements.txt | ||
RUN pip install -r /requirements.txt | ||
# script.py is the file that will contain the codes that we want to run for this action. | ||
COPY script.py /script.py | ||
# we will just run our script.py as our docker entrypoint by python script.py | ||
CMD ["python", "-u", "/script.py"] |
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,31 @@ | ||
# action-trigger-test-wait | ||
|
||
## Inputs | ||
### user | ||
**Required** - GitHub user | ||
### token | ||
**Required** - Token of user that will create issue | ||
### repo | ||
**Required** - GitHub repo name | ||
### workflow | ||
**Required** - Name of workflow file without extension | ||
### branch | ||
**Required** - branch name where build should be triggered, main is default value | ||
### group | ||
**Required** - Test group which needs to be triggered | ||
### env | ||
**Required** - Target test env such as dev,int,staging, whatever | ||
|
||
## Usages | ||
```yaml | ||
- uses: alexgocariq/action-trigger-test-wait@v1.1 | ||
name: Trigger job and wait | ||
with: | ||
user: softknife2021 | ||
token: ${{secrets.GH_AUTH_TOKEN}} | ||
repo: actions-play | ||
workflow: pr_build | ||
branch: main | ||
group: smoke | ||
env: test | ||
``` |
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,33 @@ | ||
name: Trigger Build and wait | ||
description: This action trigger build with parameters and waits | ||
inputs: | ||
user: | ||
required: true | ||
description: Github user | ||
token: | ||
required: true | ||
description: Token of the user who has permision to trigger action | ||
repo: | ||
required: true | ||
description: repo name where action will be triggered | ||
workflow: | ||
required: true | ||
description: Name of workflow yml file without extension | ||
branch: | ||
required: false | ||
default: 'main' | ||
description: Branch from where to trigger test | ||
group: | ||
required: true | ||
description: name of the test group for which test will be triggered | ||
env: | ||
required: true | ||
description: target test env | ||
|
||
runs: | ||
using: docker | ||
image: 'Dockerfile' | ||
|
||
branding: | ||
icon: arrow-down | ||
color: blue |
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,9 @@ | ||
certifi==2020.4.5.2 | ||
chardet==3.0.4 | ||
Deprecated==1.2.10 | ||
idna==2.9 | ||
PyGithub==1.51 | ||
PyJWT==1.7.1 | ||
urllib3==1.25.9 | ||
wrapt==1.12.1 | ||
requests==2.26.0 |
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,72 @@ | ||
#!/usr/bin/python3 | ||
import os | ||
import sys | ||
import time | ||
import requests | ||
import json | ||
import logging | ||
|
||
logging.basicConfig(level=logging.INFO) | ||
token = os.environ['INPUT_TOKEN'] | ||
user = os.environ['INPUT_USER'] | ||
repo = os.environ['INPUT_REPO'] | ||
workflow = os.environ['INPUT_WORKFLOW'] | ||
env = os.environ['INPUT_ENV'] | ||
group = os.environ['INPUT_GROUP'] | ||
branch = os.environ['INPUT_BRANCH'] | ||
wait_max_attempt = 60 | ||
url_trigger = "https://api.github.com/repos/{0}/{1}/actions/workflows/{2}.yaml/dispatches".format(user, repo, workflow) | ||
payload = json.dumps({ | ||
"ref": "{0}".format(branch), | ||
"inputs": { | ||
"target-env": "{0}".format(env), | ||
"test-group": "{0}".format(group), | ||
} | ||
}) | ||
headers = { | ||
'Accept': 'application/vnd.github.everest-preview+json', | ||
'Content-Type': 'application/json', | ||
'Authorization': 'Bearer {0}'.format(token) | ||
} | ||
url_dispatch = "https://api.github.com/repos/{0}/{1}/actions/runs".format(user, repo) | ||
headersGet = { | ||
'Accept': 'application/vnd.github.everest-preview+json', | ||
'Authorization': 'Bearer {0}'.format(token) | ||
} | ||
|
||
logging.info('Dispatching action') | ||
logging.info(payload) | ||
response = requests.request("POST", url_trigger, headers=headers, data=payload) | ||
if response.status_code != 204: | ||
sys.exit(response.text) | ||
time.sleep(3) | ||
|
||
workflowId = '' | ||
response = requests.request("GET", url_dispatch, headers=headersGet) | ||
if response.reason == 'OK': | ||
json = json.loads(response.text) | ||
for node in json['workflow_runs']: | ||
if node['status'] != 'completed': | ||
break | ||
workflowId = node['id'] | ||
logging.info("Found build with id {0}".format(workflowId)) | ||
counter = 0 | ||
while counter < wait_max_attempt: | ||
url = "https://api.github.com/repos/{0}/{1}/actions/runs/{2}".format(user, repo, node['id']) | ||
run = requests.request("GET", url, headers=headersGet) | ||
runJson = run.json() | ||
currentStatus = runJson['status'] | ||
logging.info("Current run id: {0} has status: {1} ".format(runJson['id'], runJson['status'])) | ||
conclusion = runJson['conclusion'] | ||
run_number = runJson['run_number'] | ||
if currentStatus == "completed": | ||
if conclusion != 'success': | ||
message = "Run number:{0} concluded with status:{1} with run has been finished".format(run_number, conclusion) | ||
assert False, message | ||
else: | ||
logging.info("Run:{0} has been finished with conclusion:{1}".format(run_number, conclusion)) | ||
break | ||
time.sleep(15) | ||
counter += 1 | ||
else: | ||
AssertionError("Failed to fetch run") |