diff --git a/.github/file-filter.yml b/.github/file-filter.yml new file mode 100644 index 0000000000..77bcefbd1f --- /dev/null +++ b/.github/file-filter.yml @@ -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' \ No newline at end of file diff --git a/.github/workflows/client.yaml b/.github/workflows/client.yaml new file mode 100644 index 0000000000..be40f0ddad --- /dev/null +++ b/.github/workflows/client.yaml @@ -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 \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000000..28e2cc523e --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/console.yml b/.github/workflows/console.yml index a497a8c8a4..d72e4815ad 100644 --- a/.github/workflows/console.yml +++ b/.github/workflows/console.yml @@ -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] @@ -53,4 +75,4 @@ jobs: working-directory: ./console run: | yarn lint - yarn typecheck + yarn typecheck \ No newline at end of file diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 3a8652f9e7..f01d530cd5 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -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 @@ -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 @@ -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 \ No newline at end of file diff --git a/client/Makefile b/client/Makefile index d395eb08a5..4d6538d224 100644 --- a/client/Makefile +++ b/client/Makefile @@ -14,5 +14,20 @@ upload-pypi: build-dev-wheel: python3 -m pip install -e . -dev-dep: - python3 -m pip install -r requirements-dev.txt \ No newline at end of file +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 . \ No newline at end of file diff --git a/client/requirements-dev.txt b/client/requirements-dev.txt index f291b447f3..a40bd2349c 100644 --- a/client/requirements-dev.txt +++ b/client/requirements-dev.txt @@ -1 +1,6 @@ -twine==4.0.0 \ No newline at end of file +twine==4.0.0 +black==22.3.0 +flake8==4.0.1 +mypy==0.950 +mypy-extensions==0.4.3 +profimp==0.1.0 \ No newline at end of file