Skip to content

Commit

Permalink
ci: add python ci (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
tianweidut committed May 11, 2022
1 parent 3c41091 commit b1ae1b0
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 10 deletions.
31 changes: 31 additions & 0 deletions .github/file-filter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
client:
- '**/*.py'
- 'client/**'

console:
- 'console/**'

docker:
- 'docker/**'

server:
- '**/*.java'
- 'server/**'

docs:
- 'docs/**'

scripts:
- 'script/**'

js:
- '**/*.js'
- '**/*.jsx'
- '**/*.ts'
- '**/*.tsx'

scss:
- '**/*.scss'

java:
- '**/*.java'
123 changes: 123 additions & 0 deletions .github/workflows/client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Python Client/SDK

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:

filter:
runs-on: ubuntu-latest

outputs:
client: ${{ steps.filter.outputs.client }}

steps:
- uses: actions/checkout@v3
- name: Check for python files changed
uses: getsentry/paths-filter@v2
id: filter
with:
base: main
filters: .github/file-filter.yml


codestyle:
runs-on: ubuntu-latest
defaults:
run:
shell: bash

needs:
- filter
if: ${{ (github.event_name == 'pull_request' && needs.filter.outputs.client == 'true') || github.event_name == 'push' }}

steps:
- uses: actions/checkout@v3

- name: Setup python
uses: actions/setup-python@v3
with:
python-version: '3.7'
architecture: 'x64'

- name: Get pip cache
id: pip-cache-path
run: echo "::set-output name=dir::$(pip cache dir)"

- name: Cache pip dependencies
uses: actions/cache@v3
id: pip-cache
with:
path: ${{ steps.pip-cache-path.outputs.dir }}
key: ${{ runner.os }}-codestyle-${{ hashFiles('client/requirements-dev.txt')}}

- name: Install dependencies
working-directory: ./client
run: |
make install-req
make install-dev-req
- name: Black format check
working-directory: ./client
run: make ci-format
- name: Lint check
working-directory: ./client
run: make ci-lint
- name: Type Check
working-directory: ./client
run: make ci-type

unittest:
runs-on: ubuntu-latest
defaults:
run:
shell: bash

needs:
- filter
if: ${{ (github.event_name == 'pull_request' && needs.filter.outputs.client == 'true') || github.event_name == 'push' }}

steps:
- uses: actions/checkout@v3

- name: Setup python
uses: actions/setup-python@v3
with:
python-version: '3.7'
architecture: 'x64'

- name: Get pip cache
id: pip-cache-path
run: echo "::set-output name=dir::$(pip cache dir)"

- name: Cache pip dependencies
uses: actions/cache@v3
id: pip-cache
with:
path: ${{ steps.pip-cache-path.outputs.dir }}
key: ${{ runner.os }}-unittest-${{ hashFiles('client/requirements-dev.txt')}}

- name: Install dependencies
working-directory: ./client
run: |
make install-req
make install-dev-req
- name: Run Unittest
working-directory: ./client
run: make ut

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.0
with:
name: codecov
fail_ci_if_error: false
directory: ./client/coverage/reports/
files: ./coverage.xml
flags: unittests
verbose: true
36 changes: 36 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "CodeQL"

on:
push:
branches: [ main ]
schedule:
- cron: '23 22 * * 4'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java', 'javascript', 'python', 'typescript' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
28 changes: 25 additions & 3 deletions .github/workflows/console.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
name: Console With Typescript
name: Console UI

on:
push:
branches:
- main
- feat/*
pull_request:
branches:
- main

jobs:

filter:
runs-on: ubuntu-latest

outputs:
console: ${{ steps.filter.outputs.console }}
js: ${{ steps.filter.outputs.js }}
scss: ${{ steps.filter.outputs.scss }}

steps:
- uses: actions/checkout@v3
- name: Check for console files changed
uses: getsentry/paths-filter@v2
id: filter
with:
base: main
filters: .github/file-filter.yml

build:
runs-on: ubuntu-latest

needs:
- filter
if: ${{ (github.event_name == 'pull_request' && needs.filter.outputs.console == 'true') || github.event_name == 'push' }}


strategy:
matrix:
node-version: [16.x]
Expand Down Expand Up @@ -53,4 +75,4 @@ jobs:
working-directory: ./console
run: |
yarn lint
yarn typecheck
yarn typecheck
29 changes: 25 additions & 4 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
name: Maven Package

on:
on:
push:
branches:
- main
- feat/*
pull_request:
branches:
- main

jobs:
build:

filter:
runs-on: ubuntu-latest

outputs:
server: ${{ steps.filter.outputs.server }}
java: ${{ steps.filter.outputs.java }}

steps:
- uses: actions/checkout@v3
- name: Check for java files changed
uses: getsentry/paths-filter@v2
id: filter
with:
base: main
filters: .github/file-filter.yml

build:
runs-on: ubuntu-latest

needs:
- filter
if: ${{ (github.event_name == 'pull_request' && needs.filter.outputs.server == 'true') || github.event_name == 'push' }}

permissions:
contents: read
packages: write
Expand All @@ -25,6 +45,7 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
Expand All @@ -35,4 +56,4 @@ jobs:
server-id: starwhale # Value of the distributionManagement/repository/id field of the pom.xml

- name: Build with Maven
run: mvn -B package --file server/pom.xml -DskipTests
run: mvn -B package --file server/pom.xml -DskipTests
19 changes: 17 additions & 2 deletions client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,20 @@ upload-pypi:
build-dev-wheel:
python3 -m pip install -e .

dev-dep:
python3 -m pip install -r requirements-dev.txt
install-dev-req:
python3 -m pip install -r requirements-dev.txt

ci-format:
echo "ci format"

ci-lint:
echo "ci lint"

ci-type:
echo "ci type"

ut:
echo "ut"

install-req:
python3 -m pip install .
7 changes: 6 additions & 1 deletion client/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
twine==4.0.0
twine==4.0.0
black==22.3.0
flake8==4.0.1
mypy==0.950
mypy-extensions==0.4.3
profimp==0.1.0

0 comments on commit b1ae1b0

Please sign in to comment.