瀏覽代碼

Create new workflow to run test of push and pull

pull/3011/head
Matheus Felipe 2 年之前
父節點
當前提交
9bb225ef3d
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: AA785C523274872F
共有 3 個文件被更改,包括 90 次插入29 次删除
  1. +0
    -29
      .github/workflows/test.yml
  2. +33
    -0
      .github/workflows/test_of_push_and_pull.yml
  3. +57
    -0
      scripts/github_pull_request.sh

+ 0
- 29
.github/workflows/test.yml 查看文件

@@ -1,29 +0,0 @@
name: "Run tests"

on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- master
pull_request:
branches:
- master

env:
FORMAT_FILE: README.md

jobs:
test:
name: 'Validate README.md'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Validate Markdown format
run: build/validate_format.py ${FORMAT_FILE}

- name: Validate pull request changes
run: build/github-pull.sh ${{ github.repository }} ${{ github.event.pull_request.number }} ${FORMAT_FILE}
if: github.event_name == 'pull_request'

+ 33
- 0
.github/workflows/test_of_push_and_pull.yml 查看文件

@@ -0,0 +1,33 @@
name: "Tests of push & pull"

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
FILENAME: README.md

jobs:
tests:
name: 'Validate README.md'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
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
run: python scripts/validate/format.py ${FILENAME}

- name: Validate pull request changes
run: scripts/github_pull_request.sh ${{ github.repository }} ${{ github.event.pull_request.number }} ${FILENAME}
if: github.event_name == 'pull_request'

+ 57
- 0
scripts/github_pull_request.sh 查看文件

@@ -0,0 +1,57 @@
#!/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

Loading…
取消
儲存