From 9edeec748c3ca5cef0a4179353c867e58d53e7d4 Mon Sep 17 00:00:00 2001 From: Tomasz Urbaszek Date: Mon, 11 Mar 2024 12:53:26 +0100 Subject: [PATCH] Refactor Github Actions (#878) --- .github/workflows/build.yaml | 79 +++---------------- .../{performance_test.yaml => lint.yaml} | 23 +++--- .github/workflows/test.yaml | 8 +- .../{e2e_test.yaml => test_e2e.yaml} | 4 +- ...ration_test.yaml => test_integration.yaml} | 6 +- ...=> test_performance_history_analysis.yaml} | 0 snowcli.spec | 51 ------------ 7 files changed, 31 insertions(+), 140 deletions(-) rename .github/workflows/{performance_test.yaml => lint.yaml} (53%) rename .github/workflows/{e2e_test.yaml => test_e2e.yaml} (96%) rename .github/workflows/{integration_test.yaml => test_integration.yaml} (95%) rename .github/workflows/{performance_history_analysis.yaml => test_performance_history_analysis.yaml} (100%) delete mode 100644 snowcli.spec diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5a02787584..63e135b0f8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -15,90 +15,29 @@ concurrency: cancel-in-progress: true jobs: - - lint: - name: Check linting - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: Install pre-commit - run: python -m pip install pre-commit - - name: Run pre-commit - run: pre-commit run --all-files - build: - name: Build packages + name: Build project runs-on: ${{ matrix.os }} needs: lint strategy: matrix: - include: - - os: macos-latest - TARGET: macos - CMD_BUILD: > - pyinstaller snowcli.spec && - cd ./dist/snow && - zip -g ../../snow.zip -r . - ARTIFACT_NAME: snow-${{ github.sha }}-darwin - PATH: snow.zip - - os: windows-latest - TARGET: windows - CMD_BUILD: pyinstaller snowcli.spec - ARTIFACT_NAME: snow-${{ github.sha }}-windows - PATH: ./dist/snow/ - - os: ubuntu-latest - TARGET: linux - CMD_BUILD: > - pyinstaller snowcli.spec && - cd ./dist/snow && - zip -g ../../snow.zip -r . - ARTIFACT_NAME: snow-${{ github.sha }}-linux - PATH: snow.zip + os: [ macos-latest, ubuntu-latest, windows-latest ] + python-version: [ "3.8", "3.10", "3.11", "3.12" ] steps: - uses: actions/checkout@v4 with: persist-credentials: false - - name: Set up Python 3.11 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: - python-version: "3.11" - - name: Install dependencies + python-version: ${{ matrix.python-version }} + - name: Install Snowflake CLI run: | python -m pip install --upgrade pip pip install . pip check snow --help - pip install -U pyinstaller - - name: Build with pyinstaller for ${{matrix.TARGET}} - run: ${{matrix.CMD_BUILD}} - - name: Archive python artifact - uses: actions/upload-artifact@v4 - with: - name: ${{matrix.ARTIFACT_NAME}} - path: ${{matrix.PATH}} - retention-days: 7 - dev-build: - name: Do dev installation - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - python-version: ["3.8", "3.12"] - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Install dev dependencies run: | - python -m pip install --upgrade pip hatch - python -m hatch run snow -h + pip install ".[development]" + pip check diff --git a/.github/workflows/performance_test.yaml b/.github/workflows/lint.yaml similarity index 53% rename from .github/workflows/performance_test.yaml rename to .github/workflows/lint.yaml index 5b7e85f446..097a0e2bb7 100644 --- a/.github/workflows/performance_test.yaml +++ b/.github/workflows/lint.yaml @@ -1,10 +1,12 @@ -name: Performance testing +name: Code quality checks on: pull_request: branches: - - main + - "*" push: + tags: + - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 branches: - main @@ -13,7 +15,8 @@ concurrency: cancel-in-progress: true jobs: - test: + lint: + name: Check code quality runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -22,12 +25,8 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.11" - - name: Install dependencies - run: | - python -m pip install --upgrade pip hatch - python -m hatch env create performance - - name: Run performance tests - env: - TERM: unknown - run: python -m hatch run performance:test + python-version: '3.x' + - name: Install pre-commit + run: python -m pip install pre-commit + - name: Run pre-commit + run: pre-commit run --all-files diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0b32788632..186908c9ac 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,6 +10,10 @@ on: branches: - main +env: + TERM: unknown # Disables colors in rich + + jobs: test: runs-on: ubuntu-latest @@ -31,7 +35,7 @@ jobs: pip install -U hatch hatch env create default - name: Test with hatch - env: - TERM: unknown run: hatch run test-cov + - name: Run performance tests + run: hatch run performance:test - uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab diff --git a/.github/workflows/e2e_test.yaml b/.github/workflows/test_e2e.yaml similarity index 96% rename from .github/workflows/e2e_test.yaml rename to .github/workflows/test_e2e.yaml index 63fe83b63d..c5bad0f0a1 100644 --- a/.github/workflows/e2e_test.yaml +++ b/.github/workflows/test_e2e.yaml @@ -15,7 +15,7 @@ concurrency: cancel-in-progress: true jobs: - test: + tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -29,7 +29,7 @@ jobs: run: | python -m pip install --upgrade pip hatch python -m hatch env create e2e - - name: Run integration tests + - name: Run end to end tests env: TERM: unknown SNOWFLAKE_CONNECTIONS_INTEGRATION_HOST: ${{ secrets.SNOWFLAKE_HOST }} diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/test_integration.yaml similarity index 95% rename from .github/workflows/integration_test.yaml rename to .github/workflows/test_integration.yaml index 06a697e3d3..38fb8e9ff1 100644 --- a/.github/workflows/integration_test.yaml +++ b/.github/workflows/test_integration.yaml @@ -15,11 +15,11 @@ concurrency: cancel-in-progress: true jobs: - test: - runs-on: ${{ matrix.os }} + tests: strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ ubuntu-latest, windows-latest ] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: diff --git a/.github/workflows/performance_history_analysis.yaml b/.github/workflows/test_performance_history_analysis.yaml similarity index 100% rename from .github/workflows/performance_history_analysis.yaml rename to .github/workflows/test_performance_history_analysis.yaml diff --git a/snowcli.spec b/snowcli.spec deleted file mode 100644 index 96364162c7..0000000000 --- a/snowcli.spec +++ /dev/null @@ -1,51 +0,0 @@ -# -*- mode: python ; coding: utf-8 -*- - - -block_cipher = None - - -a = Analysis( - ['src/snowflake/cli/app/__main__.py'], - pathex=[], - binaries=[], - datas=[('src/snowflake', 'snowflake')], - hiddenimports=[], - hookspath=[], - hooksconfig={}, - runtime_hooks=[], - excludes=[], - win_no_prefer_redirects=False, - win_private_assemblies=False, - cipher=block_cipher, - noarchive=False, -) -pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) - -exe = EXE( - pyz, - a.scripts, - [], - exclude_binaries=True, - name='snow', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - console=True, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch=None, - codesign_identity=None, - entitlements_file=None, -) - -coll = COLLECT( - exe, - a.binaries, - a.zipfiles, - a.datas, - strip=False, - upx=True, - upx_exclude=[], - name='snow', -)