Ver Fonte

[ci] add prettier check in Github Actions and fix YAML formatting (#4151)

Ram Prasad Agarwal há 5 meses atrás
pai
commit
5d8c359a1c

+ 59 - 59
.github/workflows/arm64-python-ci.yml

@@ -3,10 +3,10 @@ name: Python 3 ARM64 CI
 on:
   push:
     branches:
-    - master
+      - master
   pull_request:
     branches:
-    - master
+      - master
 
 jobs:
   hue-build-and-tests-arm64:
@@ -15,68 +15,68 @@ jobs:
     runs-on: ubuntu-22.04-arm
 
     steps:
-    - name: Checkout
-      uses: actions/checkout@v4
-      with:
-        fetch-depth: 0
-    
-    - name: Check commit title format
-      run: |
-        ./tools/ci/check_for_commit_message.sh
+      - name: Checkout
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
 
-    - name: Set up Python 3.11
-      uses: actions/setup-python@v5
-      with:
-        python-version: '3.11'
+      - name: Check commit title format
+        run: |
+          ./tools/ci/check_for_commit_message.sh
 
-    - name: Cache pip
-      uses: actions/cache@v4
-      with:
-        path: ~/.cache/pip
-        key: ${{ runner.os }}-arm64-py311-pip-${{ hashFiles('desktop/core/generate_requirements.py') }}
-        restore-keys: |
-          ${{ runner.os }}-arm64-py311-pip-
-          ${{ runner.os }}-arm64-py311-
-          ${{ runner.os }}-arm64-
+      - name: Set up Python 3.11
+        uses: actions/setup-python@v5
+        with:
+          python-version: '3.11'
 
-    - name: Setup node 20 and cache npm
-      uses: actions/setup-node@v4
-      with:
-        node-version: 20
-        cache: 'npm'
+      - name: Cache pip
+        uses: actions/cache@v4
+        with:
+          path: ~/.cache/pip
+          key: ${{ runner.os }}-arm64-py311-pip-${{ hashFiles('desktop/core/generate_requirements.py') }}
+          restore-keys: |
+            ${{ runner.os }}-arm64-py311-pip-
+            ${{ runner.os }}-arm64-py311-
+            ${{ runner.os }}-arm64-
 
-    - name: Build Hue
-      run: |
-        sudo ln -fs /usr/share/zoneinfo/UTC /etc/localtime
-        export DEBIAN_FRONTEND=noninteractive
-        sudo apt-get update -y
-        sudo apt-get install -y build-essential asciidoc libkrb5-dev libldap2-dev libsasl2-dev libxml2-dev libxslt-dev libsasl2-modules-gssapi-mit libsnappy-dev libncursesw5-dev libgdbm-dev
-        
-        # Install Python 3.11 using deadsnakes PPA
-        sudo add-apt-repository -y ppa:deadsnakes/ppa
-        sudo apt-get install -y python3.11 python3.11-dev python3.11-venv python3.11-distutils
-        
-        # Install pip for Python 3.11
-        curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3.11
-        
-        unset PIP_FIND_LINKS
-        unset PIP_EXTRA_INDEX_URL
+      - name: Setup node 20 and cache npm
+        uses: actions/setup-node@v4
+        with:
+          node-version: 20
+          cache: 'npm'
 
-        export PYTHON_VER=python3.11
-        export SKIP_PYTHONDEV_CHECK=true
-        export ROOT=$PWD
-        make apps docs test_prep
+      - name: Build Hue
+        run: |
+          sudo ln -fs /usr/share/zoneinfo/UTC /etc/localtime
+          export DEBIAN_FRONTEND=noninteractive
+          sudo apt-get update -y
+          sudo apt-get install -y build-essential asciidoc libkrb5-dev libldap2-dev libsasl2-dev libxml2-dev libxslt-dev libsasl2-modules-gssapi-mit libsnappy-dev libncursesw5-dev libgdbm-dev
 
-    - name: Run python lint check
-      run: |
-        PYTHONWARNINGS=always ./build/env/bin/hue runruff check
+          # Install Python 3.11 using deadsnakes PPA
+          sudo add-apt-repository -y ppa:deadsnakes/ppa
+          sudo apt-get install -y python3.11 python3.11-dev python3.11-venv python3.11-distutils
 
-    - name: Run unit tests
-      run: |
-        PYTHONWARNINGS=always ./build/env/bin/pytest
+          # Install pip for Python 3.11
+          curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3.11
 
-    - name: Upload reports
-      uses: actions/upload-artifact@v4
-      with:
-        name: hue-reports-arm64
-        path: ./reports
+          unset PIP_FIND_LINKS
+          unset PIP_EXTRA_INDEX_URL
+
+          export PYTHON_VER=python3.11
+          export SKIP_PYTHONDEV_CHECK=true
+          export ROOT=$PWD
+          make apps docs test_prep
+
+      - name: Run python lint check
+        run: |
+          PYTHONWARNINGS=always ./build/env/bin/hue runruff check
+
+      - name: Run unit tests
+        run: |
+          PYTHONWARNINGS=always ./build/env/bin/pytest
+
+      - name: Upload reports
+        uses: actions/upload-artifact@v4
+        with:
+          name: hue-reports-arm64
+          path: ./reports

+ 4 - 4
.github/workflows/cleanup-cache.yml

@@ -10,18 +10,18 @@ jobs:
     steps:
       - name: Checkout
         uses: actions/checkout@v4
-        
+
       - name: Cleanup
         run: |
           gh extension install actions/gh-actions-cache
-          
+
           REPO=${{ github.repository }}
           BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
 
           echo "Fetching list of cache key"
           cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
 
-          ## Setting this to not fail the workflow while deleting cache keys. 
+          ## Setting this to not fail the workflow while deleting cache keys.
           set +e
           echo "Deleting caches..."
           for cacheKey in $cacheKeysForPR
@@ -30,4 +30,4 @@ jobs:
           done
           echo "Done"
         env:
-          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

+ 31 - 28
.github/workflows/commitflow-frontend.yml

@@ -3,48 +3,51 @@ name: Frontend CI
 on:
   push:
     branches:
-    - master
+      - master
   pull_request:
     branches:
-    - master
+      - master
 
 jobs:
   hue-ui-checks-and-tests:
     runs-on: ubuntu-latest
     steps:
-    - name: Checkout
-      uses: actions/checkout@v4
+      - name: Checkout
+        uses: actions/checkout@v4
 
-    - name: Cache npm with setup node
-      uses: actions/setup-node@v4
-      with:
-        node-version: 20
-        cache: 'npm'
+      - name: Cache npm with setup node
+        uses: actions/setup-node@v4
+        with:
+          node-version: 20
+          cache: 'npm'
 
-    - name: Install npm dependencies
-      run: npm ci
+      - name: Install npm dependencies
+        run: npm ci
 
-    - name: Run commit title format check
-      run: ./tools/ci/check_for_commit_message.sh 
+      - name: Run commit title format check
+        run: ./tools/ci/check_for_commit_message.sh
 
-    - name: Run npm version checker
-      run: npm run check-pinned-versions
+      - name: Run npm version checker
+        run: npm run check-pinned-versions
 
-    - name: Run npm license checker
-      run: npm run check-license
+      - name: Run npm license checker
+        run: npm run check-license
 
-    - name: Run npm absolute path detection
-      run: npm run check-absolute-paths
+      - name: Run npm absolute path detection
+        run: npm run check-absolute-paths
 
-    - name: Run js lint check
-      run: npm run lint
+      - name: Run prettier check
+        run: npm run prettier
 
-    - name: Run style lint check
-      run: npm run style-lint
+      - name: Run js lint check
+        run: npm run lint
 
-    - name: Run js tests
-      run: |
-        # https://jestjs.io/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-andor-continuous-integration-ci-server
-        sed -i 's/"test": "jest"/"test": "jest --runInBand"/g' package.json
+      - name: Run style lint check
+        run: npm run style-lint
 
-        npm run test
+      - name: Run js tests
+        run: |
+          # https://jestjs.io/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-andor-continuous-integration-ci-server
+          sed -i 's/"test": "jest"/"test": "jest --runInBand"/g' package.json
+
+          npm run test

+ 55 - 57
.github/workflows/commitflow-py3.yml

@@ -3,13 +3,12 @@ name: Python 3 CI
 on:
   push:
     branches:
-    - master
+      - master
   pull_request:
     branches:
-    - master
+      - master
 jobs:
   hue-build-and-tests:
-
     runs-on: ubuntu-latest
 
     strategy:
@@ -17,66 +16,65 @@ jobs:
         python-version: ['3.8', '3.9', '3.10', '3.11']
 
     steps:
-    - name: Checkout
-      uses: actions/checkout@v4
-      with:
-        fetch-depth: 0
-
-    - name: Check commit title format
-      run: |
-        ./tools/ci/check_for_commit_message.sh
+      - name: Checkout
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
 
-    - name: Set up Python ${{ matrix.python-version }}
-      uses: actions/setup-python@v5
-      with:
-        python-version: ${{ matrix.python-version }}
+      - name: Check commit title format
+        run: |
+          ./tools/ci/check_for_commit_message.sh
 
-    - name: Cache pip
-      uses: actions/cache@v4
-      with:
-        # This path is specific to Ubuntu
-        path: ~/.cache/pip
-        key: ${{ runner.os }}-pip-${{ hashFiles('desktop/core/generate_requirements.py') }}
-        restore-keys: |
-          ${{ runner.os }}-pip-
-          ${{ runner.os }}-
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v5
+        with:
+          python-version: ${{ matrix.python-version }}
 
-    - name: Setup node 20 and cache npm
-      uses: actions/setup-node@v4
-      with:
-        node-version: 20
-        cache: 'npm'
+      - name: Cache pip
+        uses: actions/cache@v4
+        with:
+          # This path is specific to Ubuntu
+          path: ~/.cache/pip
+          key: ${{ runner.os }}-pip-${{ hashFiles('desktop/core/generate_requirements.py') }}
+          restore-keys: |
+            ${{ runner.os }}-pip-
+            ${{ runner.os }}-
 
-    - name: Build Hue
-      run: |
-        sudo apt-get update
-        sudo apt-get install -y build-essential asciidoc libkrb5-dev libldap2-dev libsasl2-dev libxslt-dev libsasl2-modules-gssapi-mit libsnappy-dev libgdbm-dev
+      - name: Setup node 20 and cache npm
+        uses: actions/setup-node@v4
+        with:
+          node-version: 20
+          cache: 'npm'
 
-        export PYTHON_VER=python${{ matrix.python-version }}
-        export SKIP_PYTHONDEV_CHECK=true
-        export ROOT=$PWD
-        make apps test_prep
+      - name: Build Hue
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y build-essential asciidoc libkrb5-dev libldap2-dev libsasl2-dev libxslt-dev libsasl2-modules-gssapi-mit libsnappy-dev libgdbm-dev
 
-    - name: Run unit tests
-      run: |
-        if [[ "${{ matrix.python-version }}" == "3.11" ]]; then
-          ./build/env/bin/pytest
-        else
-          ./build/venvs/python${{ matrix.python-version }}/bin/pytest
-        fi
+          export PYTHON_VER=python${{ matrix.python-version }}
+          export SKIP_PYTHONDEV_CHECK=true
+          export ROOT=$PWD
+          make apps test_prep
 
-    - name: Run python lint check
-      run: |
-        if [[ "${{ matrix.python-version }}" == "3.11" ]]; then
-          PYTHONWARNINGS=always ./build/env/bin/hue runruff check
-        else
-          PYTHONWARNINGS=always ./build/venvs/python${{ matrix.python-version }}/bin/hue runruff check
-        fi
+      - name: Run unit tests
+        run: |
+          if [[ "${{ matrix.python-version }}" == "3.11" ]]; then
+            ./build/env/bin/pytest
+          else
+            ./build/venvs/python${{ matrix.python-version }}/bin/pytest
+          fi
 
-    - name: Upload reports
-      if: matrix.python-version == '3.11'
-      uses: actions/upload-artifact@v4
-      with:
-        name: hue-reports
-        path: ./reports
+      - name: Run python lint check
+        run: |
+          if [[ "${{ matrix.python-version }}" == "3.11" ]]; then
+            PYTHONWARNINGS=always ./build/env/bin/hue runruff check
+          else
+            PYTHONWARNINGS=always ./build/venvs/python${{ matrix.python-version }}/bin/hue runruff check
+          fi
 
+      - name: Upload reports
+        if: matrix.python-version == '3.11'
+        uses: actions/upload-artifact@v4
+        with:
+          name: hue-reports
+          path: ./reports

+ 1 - 1
.github/workflows/docs_lint.yml

@@ -32,7 +32,7 @@ jobs:
         with:
           # point at your local server URL
           args: http://localhost:1313/ --exclude "https://issues.cloudera.org*|http://localhost:8005|http://localhost:5555*|https://issues.apache.org/jira*|https://github.com*|http://demo.gethue.com*|https://twitter.com/gethue|https://cdn.gethue.com/downloads/*|https://pypi.org*"
-          fail: true  # fail the job if any broken links are found
+          fail: true # fail the job if any broken links are found
           format: markdown
 
       - name: Tear down Hugo

+ 8 - 8
.github/workflows/pr-comments.yml

@@ -30,13 +30,13 @@ jobs:
           restore-keys: |
             ${{ runner.os }}-pip-
             ${{ runner.os }}-
-      
+
       - name: Setup node 20 and cache npm
         uses: actions/setup-node@v4
         with:
           node-version: 20
           cache: 'npm'
-      
+
       - name: Build Hue
         run: |
           sudo apt-get update
@@ -51,7 +51,7 @@ jobs:
         continue-on-error: true
         run: |
           ./build/env/bin/pytest
-      
+
       - name: Add pytest and code coverage PR comment
         uses: MishaKav/pytest-coverage-comment@v1
         with:
@@ -64,7 +64,7 @@ jobs:
           xml-skip-covered: true
           remove-link-from-badge: true
           default-branch: master
-  
+
   python-ut-files-check:
     runs-on: ubuntu-latest
     steps:
@@ -94,9 +94,9 @@ jobs:
       - name: Update PR with test file change status
         uses: mshick/add-pr-comment@v2
         with:
-          message: "${{ env.comment_message }}"
+          message: '${{ env.comment_message }}'
           allow-repeats: false
-  
+
   ui-tests-and-coverage:
     runs-on: ubuntu-latest
     steps:
@@ -111,12 +111,12 @@ jobs:
 
       - name: Install npm dependencies
         run: npm ci
-      
+
       - name: Run js tests with coverage
         run: |
           # https://jestjs.io/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-andor-continuous-integration-ci-server
           npm run test-coverage -- --runInBand
-      
+
       - name: Add jest coverage PR comment
         uses: MishaKav/jest-coverage-comment@v1
         with: