Unverified Commit 9bb225ef authored by Matheus Felipe's avatar Matheus Felipe
Browse files

Create new workflow to run test of push and pull

parent bc02fa51
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:
FORMAT_FILE: README.md FILENAME: README.md
jobs: jobs:
test: tests:
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 ${FORMAT_FILE} run: python scripts/validate/format.py ${FILENAME}
- name: Validate pull request changes - name: Validate pull request changes
run: build/github-pull.sh ${{ github.repository }} ${{ github.event.pull_request.number }} ${FORMAT_FILE} run: scripts/github_pull_request.sh ${{ github.repository }} ${{ github.event.pull_request.number }} ${FILENAME}
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
#!/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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment