From 9165832084c6a5e5df4bdf1f947bdc79aeaf3877 Mon Sep 17 00:00:00 2001 From: Asif Nawaz Date: Fri, 5 Apr 2024 10:13:38 +0100 Subject: [PATCH] ci(workflows): reviewed workflow files to use reusable workflows --- .../workflows/auto-merge-dependabot-pr.yml | 35 ---- .github/workflows/release.yml | 195 +----------------- .github/workflows/test.yml | 45 +--- 3 files changed, 10 insertions(+), 265 deletions(-) delete mode 100644 .github/workflows/auto-merge-dependabot-pr.yml diff --git a/.github/workflows/auto-merge-dependabot-pr.yml b/.github/workflows/auto-merge-dependabot-pr.yml deleted file mode 100644 index 268ddba..0000000 --- a/.github/workflows/auto-merge-dependabot-pr.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Dependabot auto-merge -on: - pull_request: - types: - - opened - - synchronize - -jobs: - tests: - uses: ./.github/workflows/test.yml - secrets: inherit - permissions: - contents: read - - dependabot: - if: ${{ github.actor == 'dependabot[bot]' }} - name: Auto-merge Dependabot PR - runs-on: ${{ vars.RTLDEV_MW_CI_OS }} - needs: tests - permissions: - contents: write - pull-requests: write - steps: - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v2 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - name: Enable auto-merge for Dependabot PRs - # (fixes, features but not major upgrades!) - if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'}} - run: gh pr merge --auto -d -r "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.RTLDEV_MW_CI_TOKEN}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4d50bff..d2cd16f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,198 +4,7 @@ on: branches: - master -env: - PYTHON_MIN_VERSION: ${{ vars.RTLDEV_MW_CI_PYTHON_VERSION }} - jobs: - build: - name: Build - uses: ./.github/workflows/test.yml - secrets: inherit - permissions: - contents: read - - generate-linux-bin: - permissions: - contents: write - deployments: write - name: Generate Linux bin - needs: build - runs-on: ${{ vars.RTLDEV_MW_CI_OS }} - steps: - - name: Checkout branch - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Number of commits to fetch. 0 indicates all history for all branches and tags. - - name: Checkout python - uses: actions/setup-python@v5 - with: - check-latest: true - python-version: ${{ vars.RTLDEV_MW_CI_PYTHON_VERSION }} - - name: Install python dependencies - run: | - pip install --upgrade pip - pip -V - pip install --upgrade -e . - - name: Setup NodeJS LTS - uses: actions/setup-node@v4 - with: - node-version: '${{ vars.RTLDEV_MW_CI_NODE_VERSION }}' - check-latest: true - cache: npm - - name: Install NodeJS dependencies - run: npm ci - - name: Release - version update only - run: | - echo '{"plugins": ["@semantic-release/commit-analyzer", ["@semantic-release/exec", { "verifyReleaseCmd": "./updateVersion.sh ${nextRelease.version}" }]]}' > '.releaserc.json' - cat .releaserc.json - npx semantic-release --dry-run - - name: Run Pyinstaller - run: | - "./scripts/linux-pyinstaller.sh" - - name: Upload linux-binary - uses: actions/upload-artifact@v4 - with: - name: linux-binary - path: linux-binary-latest.zip - retention-days: 1 - generate-macos-bin: - name: Generate MacOS bin - runs-on: macos-latest - needs: build - permissions: - contents: write - deployments: write - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Number of commits to fetch. 0 indicates all history for all branches and tags. - - name: Checkout python - uses: actions/setup-python@v5 - with: - check-latest: true - python-version: ${{ vars.RTLDEV_MW_CI_PYTHON_VERSION }} - - name: Install dependencies - run: | - pip install --upgrade pip - pip -V - pip install --upgrade -e . - - name: Setup NodeJS LTS - uses: actions/setup-node@v4 - with: - node-version: '${{ vars.RTLDEV_MW_CI_NODE_VERSION }}' - check-latest: true - cache: npm - - name: Install NodeJS dependencies - run: npm ci - - name: Release - version update only - run: | - echo '{"plugins": ["@semantic-release/commit-analyzer", ["@semantic-release/exec", { "verifyReleaseCmd": "./updateVersionMacOS.sh ${nextRelease.version}" }]]}' > '.releaserc.json' - cat .releaserc.json - npx semantic-release --dry-run - - name: Run Pyinstaller - run: | - "./scripts/macos-pyinstaller.sh" - - name: Upload macos-binary - uses: actions/upload-artifact@v4 - with: - name: macos-binary - path: macos-binary-latest.zip - retention-days: 1 - - generate-win-bin: - name: Generate Win bin - runs-on: windows-latest - needs: build - permissions: - contents: write - deployments: write - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Number of commits to fetch. 0 indicates all history for all branches and tags. - - name: Checkout python - uses: actions/setup-python@v5 - with: - check-latest: true - python-version: ${{ vars.RTLDEV_MW_CI_PYTHON_VERSION }} - - name: Install python dependencies - run: | - pip install --upgrade pip - pip -V - pip install --upgrade -e . - - name: Setup NodeJS LTS - uses: actions/setup-node@v4 - with: - node-version: '${{ vars.RTLDEV_MW_CI_NODE_VERSION }}' - check-latest: true - cache: npm - - name: Install NodeJS dependencies - run: npm ci - - name: Release - version update only - run: | - echo '{"plugins": ["@semantic-release/commit-analyzer", ["@semantic-release/exec", { "verifyReleaseCmd": "Bash updateVersion.sh ${nextRelease.version}" }]]}' > '.releaserc.json' - cat .releaserc.json - npx semantic-release --dry-run - - name: Run Pyinstaller - run: | - & "./scripts/win-pyinstaller.ps1" - - name: Upload win-binary - uses: actions/upload-artifact@v4 - with: - name: win-binary - path: win-binary-latest.zip - retention-days: 1 - release: - name: Release Job - runs-on: ${{ vars.RTLDEV_MW_CI_OS }} - needs: - - generate-linux-bin - - generate-macos-bin - - generate-win-bin - permissions: - contents: write - issues: write - deployments: write - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Number of commits to fetch. 0 indicates all history for all branches and tags. - persist-credentials: false - - name: Checkout python - uses: actions/setup-python@v5 - with: - check-latest: true - python-version: ${{ vars.RTLDEV_MW_CI_PYTHON_VERSION }} - - name: Install dependencies - run: | - pip install --upgrade pip testresources setuptools wheel - pip -V - pip install --upgrade -e . - - name: Setup NodeJS LTS - uses: actions/setup-node@v4 - with: - node-version: '${{ vars.RTLDEV_MW_CI_NODE_VERSION }}' - check-latest: true - cache: npm - - name: Install dependencies - run: | - npm ci - gulp validate - - name: Download Artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.RTLDEV_MW_CI_TOKEN }} - TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - TEAMS_NOTIFICATION_URI: ${{ secrets.RTLDEV_MW_CI_NOTIFICATION_URI }} - COMMIT_SHA: ${{ github.sha }} - run: npx semantic-release + uses: centralnicgroup-opensource/rtldev-middleware-shareable-workflows/.github/workflows/ispapicli-release.yml@main + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a4e00ec..3f5395a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,40 +1,11 @@ -name: Linting & Coverage +name: Dependabot auto-merge & tests on: - workflow_call: + pull_request: + types: + - opened + - synchronize jobs: - test: - name: 🧪 Linting & Testing - runs-on: ${{ vars.RTLDEV_MW_CI_OS }} - permissions: - contents: read - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - persist-credentials: false - - uses: actions/setup-python@v5 - with: - check-latest: true - python-version: ${{ vars.RTLDEV_MW_CI_PYTHON_VERSION }} - - name: Install dependencies - run: | - pip install --upgrade pip - pip -V - pip install --upgrade -e . - - name: Python version - run: | - echo "Python version: " - echo ${{ vars.RTLDEV_MW_CI_PYTHON_VERSION }} | sed 's/./&‎/g' - - name: Super Linter Code Base - uses: github/super-linter/slim@v5 - env: - FILTER_REGEX_INCLUDE: "/hexonet/*|/scripts/*|updateVersion*.sh|setup.py" - DEFAULT_BRANCH: master - VALIDATE_PYTHON_BLACK: true - VALIDATE_BASH: true - VALIDATE_ALL_CODEBASE: true - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Coverage Report - run: "./scripts/coverage.sh" + tests: + uses: centralnicgroup-opensource/rtldev-middleware-shareable-workflows/.github/workflows/ispapicli-test.yml@main + secrets: inherit \ No newline at end of file