Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
public-apis
Commits
9bb225ef
Unverified
Commit
9bb225ef
authored
Jan 17, 2022
by
Matheus Felipe
Browse files
Create new workflow to run test of push and pull
parent
bc02fa51
Changes
2
Hide whitespace changes
Inline
Side-by-side
.github/workflows/test.yml
→
.github/workflows/test
_of_push_and_pull
.yml
View file @
9bb225ef
name
:
"
Run
tests
"
name
:
"
Tests
of
push
&
pull
"
on
:
on
:
schedule
:
-
cron
:
'
0
0
*
*
*'
push
:
push
:
branches
:
branches
:
[
master
]
-
master
pull_request
:
pull_request
:
branches
:
branches
:
[
master
]
-
master
env
:
env
:
F
ORMAT_FIL
E
:
README.md
F
ILENAM
E
:
README.md
jobs
:
jobs
:
test
:
test
s
:
name
:
'
Validate
README.md'
name
:
'
Validate
README.md'
runs-on
:
ubuntu-latest
runs-on
:
ubuntu-latest
steps
:
steps
:
-
name
:
Checkout repository
-
name
:
Checkout repository
uses
:
actions/checkout@v2
uses
:
actions/checkout@v2
-
name
:
Set up Python
uses
:
actions/setup-python@v2
with
:
python-version
:
'
3.8'
-
name
:
Install dependencies
run
:
python -m pip install -r scripts/requirements.txt
-
name
:
Validate Markdown format
-
name
:
Validate Markdown format
run
:
build
/validate
_
format.py ${F
ORMAT_FIL
E}
run
:
python scripts
/validate
/
format.py ${F
ILENAM
E}
-
name
:
Validate pull request changes
-
name
:
Validate pull request changes
run
:
build
/github
-
pull.sh ${{ github.repository }} ${{ github.event.pull_request.number }} ${F
ORMAT_FIL
E}
run
:
scripts
/github
_
pull
_request
.sh ${{ github.repository }} ${{ github.event.pull_request.number }} ${F
ILENAM
E}
if
:
github.event_name == 'pull_request'
if
:
github.event_name == 'pull_request'
scripts/github_pull_request.sh
0 → 100644
View file @
9bb225ef
#!/usr/bin/env bash
set
-e
# Argument validation
if
[
$#
-ne
3
]
;
then
echo
"Usage:
$0
<github-repo> <pull-number> <filename>"
exit
1
fi
# Assign variables
GITHUB_REPOSITORY
=
"
$1
"
GITHUB_PULL_REQUEST
=
"
$2
"
FILENAME
=
"
$3
"
# Move to root of project
cd
"
$GITHUB_WORKSPACE
"
# Determine files
FILENAME
=
"
$(
realpath
"
${
FILENAME
}
"
)
"
# Skip if build number could not be determined
if
[
-z
"
$GITHUB_REPOSITORY
"
-o
-z
"
$GITHUB_PULL_REQUEST
"
]
;
then
echo
"No pull request and/or repository is provided"
exit
1
fi
# Pull changes on PR
echo
"running on Pull Request #
$GITHUB_PULL_REQUEST
"
# Trick the URL validator python script into not seeing this as a URL
DUMMY_SCHEME
=
"https"
DIFF_URL
=
"
$DUMMY_SCHEME
://patch-diff.githubusercontent.com/raw/
$GITHUB_REPOSITORY
/pull/
$GITHUB_PULL_REQUEST
.diff"
curl
-L
"
$DIFF_URL
"
-o
diff.txt
# Construct diff
echo
"------- BEGIN DIFF -------"
cat
diff.txt
echo
"-------- END DIFF --------"
cat
diff.txt | egrep
"
\+
"
>
additions.txt
echo
"------ BEGIN ADDITIONS -----"
cat
additions.txt
echo
"------- END ADDITIONS ------"
LINK_FILE
=
additions.txt
# Validate links
echo
"Running link validation on additions..."
python scripts/validate/links.py
"
$LINK_FILE
"
# Vebosity
if
[[
$?
!=
0
]]
;
then
echo
"link validation failed on additions!"
exit
1
else
echo
"link validation passed on additions!"
fi
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment