docs: 修复README.md中的类型安全表情符号显示问题 #50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [ published ] | |
| jobs: | |
| test-go: | |
| name: Test Go Code | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.24' | |
| - name: Cache Go modules | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run tests | |
| run: | | |
| if [ -n "$(find . -name '*_test.go' -type f)" ]; then | |
| go test -v ./... | |
| else | |
| echo "No test files found, skipping tests" | |
| fi | |
| - name: Build | |
| run: go build -v . | |
| test-python: | |
| name: Test Python SDK | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.8', '3.9', '3.10', '3.11'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip packages | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('python-sdk/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| working-directory: ./python-sdk | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest pytest-asyncio | |
| - name: Run tests | |
| working-directory: ./python-sdk | |
| run: | | |
| if [ -d "tests" ]; then | |
| python -m pytest tests/ -v | |
| else | |
| echo "No tests directory found, skipping tests" | |
| fi | |
| - name: Test import | |
| working-directory: ./python-sdk | |
| run: | | |
| python -c "import scheduler, worker; print('Import successful')" | |
| test-nodejs: | |
| name: Test Node.js SDK | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: ['16', '18', '20'] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| cache-dependency-path: 'node-sdk/package-lock.json' | |
| - name: Install dependencies | |
| working-directory: ./node-sdk | |
| run: npm ci | |
| - name: Run tests | |
| working-directory: ./node-sdk | |
| run: | | |
| if npm run test --silent 2>/dev/null; then | |
| npm test | |
| else | |
| echo "No test script found, skipping tests" | |
| fi | |
| - name: Test import | |
| working-directory: ./node-sdk | |
| run: | | |
| node -e "const { SchedulerClient, Worker } = require('./index.js'); console.log('Import successful');" | |
| publish-npm: | |
| name: Publish to NPM | |
| needs: [test-go, test-python, test-nodejs] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| working-directory: ./node-sdk | |
| run: npm ci | |
| - name: Publish to NPM | |
| working-directory: ./node-sdk | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| publish-pypi: | |
| name: Publish to PyPI | |
| needs: [test-go, test-python, test-nodejs] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| working-directory: ./python-sdk | |
| run: python -m build | |
| - name: Publish to PyPI | |
| working-directory: ./python-sdk | |
| run: twine upload dist/* | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
| build-release: | |
| name: Build Release Binaries | |
| needs: [test-go, test-python, test-nodejs] | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' | |
| strategy: | |
| matrix: | |
| goos: [linux, windows, darwin] | |
| goarch: [amd64, arm64] | |
| exclude: | |
| - goos: windows | |
| goarch: arm64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Build binary | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| run: | | |
| mkdir -p dist | |
| if [ "$GOOS" = "windows" ]; then | |
| go build -o dist/go-server-${{ matrix.goos }}-${{ matrix.goarch }}.exe . | |
| else | |
| go build -o dist/go-server-${{ matrix.goos }}-${{ matrix.goarch }} . | |
| fi | |
| - name: Upload Release Asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ github.event.release.upload_url }} | |
| asset_path: ./dist/go-server-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} | |
| asset_name: go-server-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} | |
| asset_content_type: application/octet-stream |