Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggg #27

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

ggg #27

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/actions/create_status_check/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const core = require("@actions/core");
const github = require("@actions/github");

async function run() {
try {
const [
gitHubRepoOwner,
gitHubRepoName
] = process.env.GITHUB_REPOSITORY.split("/");
const gitHubSha = process.env.GITHUB_SHA;
const gitHubToken = core.getInput("github-token");

const octokit = new github.GitHub(gitHubToken);

octokit.checks.create({
owner: gitHubRepoOwner,
repo: gitHubRepoName,
name: "Check Created by API",
head_sha: gitHubSha,
status: "completed",
conclusion: "success",
output: {
title: "Check Created by API",
summary: `# All good ![step 1](https://www.imore.com/sites/imore.com/files/styles/w1600h900crop/public/field/image/2019/07/pokemonswordshieldstartertrio.jpg "Step 1")`
}
});

core.setOutput("time", new Date().toTimeString());
} catch (error) {
core.setFailed(error.message);
}
}

run();
2 changes: 1 addition & 1 deletion .github/workflows/gardener.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Taichi Gardener
on:
pull_request:
types: [review_requested, synchronize]
types: [review_requested]

jobs:
format:
Expand Down
209 changes: 27 additions & 182 deletions .github/workflows/persubmit.yml
Original file line number Diff line number Diff line change
@@ -1,201 +1,46 @@
name: Persubmit Checks
on:
pull_request:
types: [opened, synchronize, reopened]
repository_dispatch:
types: [format-command]

jobs:
build_and_test_cpu_required:
# This job will be required to pass before merging to master branch.
name: Required Build and Test (CPU)
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip ci') }}
strategy:
matrix:
include:
- os: ubuntu-latest
python: 3.6
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

- name: Download Pre-Built LLVM 10.0.0
run: |
python misc/ci_download.py
mkdir taichi-llvm
cd taichi-llvm
unzip ../taichi-llvm.zip
env:
CI_PLATFORM: ${{ matrix.os }}

- name: Build
run: |
export TAICHI_REPO_DIR=`pwd`
export PATH=$TAICHI_REPO_DIR/taichi-llvm/bin/:$PATH
export CXX=clang++
python misc/ci_setup.py ci
env:
CI_SETUP_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=ON -DTI_BUILD_TESTS:BOOL=ON

- name: Test
run: |
export TAICHI_REPO_DIR=`pwd`
export PATH=$TAICHI_REPO_DIR/bin:$PATH
export PATH=$TAICHI_REPO_DIR/taichi-llvm/bin/:$PATH
export PYTHONPATH=$TAICHI_REPO_DIR/python
python examples/laplace.py
ti diagnose
./build/taichi_cpp_tests
ti test -vr2 -t2

build_and_test_cpu:
name: Build and Test (CPU)
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip ci') && github.event.sender.login != 'taichi-gardener' }}
strategy:
matrix:
include:
- os: macos-latest
python: 3.7
with_cc: OFF
with_cpp_tests: ON
- os: ubuntu-latest
python: 3.9
with_cc: OFF
with_cpp_tests: OFF
- os: ubuntu-latest
python: 3.8
with_cc: ON
with_cpp_tests: OFF
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

- name: Download Pre-Built LLVM 10.0.0
run: |
python misc/ci_download.py
mkdir taichi-llvm
cd taichi-llvm
unzip ../taichi-llvm.zip
env:
CI_PLATFORM: ${{ matrix.os }}

- name: Build
run: |
export TAICHI_REPO_DIR=`pwd`
export PATH=$TAICHI_REPO_DIR/taichi-llvm/bin/:$PATH
export CXX=clang++
python misc/ci_setup.py ci
env:
CI_SETUP_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=${{ matrix.with_cc }} -DTI_BUILD_TESTS:BOOL=${{ matrix.with_cpp_tests }}

- name: Test
run: |
export TAICHI_REPO_DIR=`pwd`
export PATH=$TAICHI_REPO_DIR/bin:$PATH
export PATH=$TAICHI_REPO_DIR/taichi-llvm/bin/:$PATH
export PYTHONPATH=$TAICHI_REPO_DIR/python
python examples/laplace.py
ti diagnose
[ "$RUN_CPP_TESTS" = "ON" ] && ./build/taichi_cpp_tests
ti test -vr2 -t2
env:
RUN_CPP_TESTS: ${{ matrix.with_cpp_tests }}

build_and_test_gpu:
name: Build and Test (GPU)
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip ci') && github.event.sender.login != 'taichi-gardener' }}
runs-on: [zhen]
steps:
- uses: actions/checkout@v2

- name: Build
run: |
git --version
export TAICHI_REPO_DIR=`pwd`
export PATH=/home/github/taichi-llvm/bin/:$PATH
export CXX=clang++-8
export PYTHON=/usr/bin/python3.7
$PYTHON misc/ci_setup.py ci
env:
CI_SETUP_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=ON -DTI_WITH_CC:BOOL=OFF

- name: Test
run: |
export PYTHON=/usr/bin/python3.7
export TAICHI_REPO_DIR=`pwd`
export PATH=$TAICHI_REPO_DIR/bin:$PATH
export PATH=/home/github/taichi-llvm/bin/:$PATH
export PYTHONPATH=$TAICHI_REPO_DIR/python
export DISPLAY=:1
glewinfo
$PYTHON examples/laplace.py
ti diagnose
ti test -vr2 -t2

check_previous_run:
name: Checks the Workflow Run of the Previous Commit
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'skip ci') || github.event.sender.login == 'taichi-gardener' }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Check the previous run
env:
PR: ${{ github.event.pull_request.number }}
SHA: ${{ github.event.pull_request.head.sha }}
# https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
# https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
# Do not leak the secret
OAUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python misc/ci_check_previous_run.py --pr "${PR}" --sha "${SHA}" --token "${OAUTH_TOKEN}"

jobs:
code_format:
name: Code Format
runs-on: ubuntu-latest
# This job will be required to pass before merging to master branch.
steps:
- uses: actions/checkout@v2
- name: clone branch of PR
uses: actions/checkout@v2
with:
token: ${{ secrets.GARDENER_PAT }}
#ref: ${{ steps.pr_data.outputs.branch }}
#repository: ${{ steps.pr_data.outputs.repo_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Check code format
- name: Check and change code format
run: |
git fetch https://github.com/taichi-dev/taichi.git refs/heads/master
git checkout -b _tmp_format
git checkout ${{ github.event.client_payload.pull_request.head.ref }}
git fetch https://github.com/taichi-dev/test_actions.git refs/heads/master
git reset FETCH_HEAD
python3 -m pip install yapf gitpython colorama isort
python3 python/taichi/code_format.py
git reset _tmp_format
echo "# hahaha" >> python/build.py
git add .
git config user.email "[email protected]"
git config user.name "Taichi Gardener"
git commit -m "fake squash commit" || true
git checkout -b _last_squash
git checkout -b _enforced_format
git reset FETCH_HEAD
python3 -m pip install --user yapf gitpython colorama
python3 python/taichi/code_format.py
git add .
git commit -m "enforce code format" || true
# exit with 1 if there were differences:
git diff _last_squash _enforced_format --exit-code

title_format:
name: Check PR Title
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
git commit -m "Auto Format" || true
git merge FETCH_HEAD
- name: Push changes
uses: ad-m/github-push-action@master
with:
python-version: 3.8

- name: Run PR Title Checker
run: |
pip install semver GitPython
python misc/ci_check_pr_title.py "$PR_TITLE"
env:
PR_TITLE: ${{ github.event.pull_request.title }}
GITHUB_TOKEN: ${{ secrets.GARDENER_PAT }}
branch: ${{ github.event.client_payload.pull_request.head.ref }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- os: macos-latest
python: 3.8
with_cc: OFF
- os: macos-latest
python: 3.9
with_cc: OFF
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/reply_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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.GARDENER_PAT }}
reaction-token: ${{ secrets.GARDENER_PAT }}
commands: |
format
6 changes: 6 additions & 0 deletions python/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

def get_os_name():
name = platform.platform()

# in python 3.8, platform.platform() uses mac_ver() on macOS
# it will return 'macOS-XXXX' instead of 'Darwin-XXXX'

if name.lower().startswith('darwin') or name.lower().startswith('macos'):
return 'osx'
elif name.lower().startswith('windows'):
Expand Down Expand Up @@ -186,3 +188,7 @@ def main():

if __name__ == '__main__':
main()
# hahaha
# hahaha
# hahaha
# hahaha
2 changes: 1 addition & 1 deletion python/taichi/code_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def format_file(fn):
format_plain_text(fn)
return True
elif has_suffix(fn, [
'txt', 'md', 'rst', 'cfg', 'yml', 'ini', 'map', 'cmake'
'txt', 'md', 'rst', 'cfg', 'ini', 'map', 'cmake'
]) or (os.path.basename(fn)[0].isupper()
and fn.endswith('file')): # E.g., Dockerfile and Jenkinsfile
format_plain_text(fn)
Expand Down