From c3e033939cccc2ea50f0194cbc59de6fc5265be6 Mon Sep 17 00:00:00 2001 From: Ivan <98037481+IvanZosimov@users.noreply.github.com> Date: Thu, 22 Dec 2022 11:17:13 +0200 Subject: [PATCH] Update action to use reusable workflows (#569) * Update workflows to use reusable-workflows * Update licensed.yml * Update workflows * Add links to reusable workflows * Update action to use reusable-workflows repo * Fix review points --- .github/workflows/basic-validation.yml | 15 +++++++ .github/workflows/check-dist.yml | 41 ++--------------- .github/workflows/codeql-analysis.yml | 44 +++---------------- .../workflows/{workflow.yml => e2e-tests.yml} | 25 +++-------- .github/workflows/licensed.yml | 21 ++------- .../workflows/release-new-action-version.yml | 3 +- .github/workflows/test-pypy.yml | 1 + .github/workflows/test-python.yml | 1 + package.json | 1 + 9 files changed, 37 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/basic-validation.yml rename .github/workflows/{workflow.yml => e2e-tests.yml} (86%) diff --git a/.github/workflows/basic-validation.yml b/.github/workflows/basic-validation.yml new file mode 100644 index 00000000..f69f9a1d --- /dev/null +++ b/.github/workflows/basic-validation.yml @@ -0,0 +1,15 @@ +name: Basic validation + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + pull_request: + paths-ignore: + - '**.md' +jobs: + call-basic-validation: + name: Basic validation + uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main \ No newline at end of file diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 6274fd28..1251c11d 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -1,8 +1,3 @@ -# `dist/index.js` is a special file in Actions. -# When you reference an action with `uses:` in a workflow, -# `index.js` is the code that will run. -# For our project, we generate this file through a build process from other source files. -# We need to make sure the checked-in `index.js` actually matches what we expect it to be. name: Check dist/ on: @@ -17,36 +12,6 @@ on: workflow_dispatch: jobs: - check-dist: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Set Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - cache: npm - - - name: Install dependencies - run: npm ci - - - name: Rebuild the dist/ directory - run: npm run build - - - name: Compare the expected and actual dist/ directories - run: | - if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then - echo "Detected uncommitted changes after build. See status below:" - git diff - exit 1 - fi - id: diff - - # If index.js was different than expected, upload the expected version as an artifact - - uses: actions/upload-artifact@v3 - if: ${{ failure() && steps.diff.conclusion == 'failure' }} - with: - name: dist - path: dist/ + call-check-dist: + name: Check dist/ + uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3ea240d8..fd273502 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,47 +1,13 @@ -name: "Code scanning - action" +name: CodeQL analysis on: push: branches: [ 'main' ] pull_request: schedule: - - cron: '25 3 * * 5' + - cron: '0 3 * * 0' jobs: - CodeQL-Build: - - strategy: - fail-fast: false - - # CodeQL runs on ubuntu-latest and windows-latest - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - # Override language selection by uncommenting this and choosing your languages - # with: - # languages: go, javascript, csharp, python, cpp, java - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + call-codeQL-analysis: + name: CodeQL analysis + uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/e2e-tests.yml similarity index 86% rename from .github/workflows/workflow.yml rename to .github/workflows/e2e-tests.yml index 3575845e..21dead7e 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/e2e-tests.yml @@ -1,4 +1,5 @@ -name: Main workflow +name: e2e tests + on: push: branches: @@ -8,9 +9,10 @@ on: pull_request: paths-ignore: - '**.md' + jobs: - run: - name: Run + test-setup-python: + name: Test setup-python runs-on: ${{ matrix.operating-system }} strategy: matrix: @@ -19,21 +21,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Set Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - cache: npm - - - name: npm ci - run: npm ci - - - name: Lint - run: npm run format-check - - - name: npm test - run: npm test - - name: Run with setup-python 2.7 uses: ./ with: @@ -98,4 +85,4 @@ jobs: - name: Verify 3.10 run: python __tests__/verify-python.py 3.10 - name: Run python-path sample 3.10 - run: pipx run --python '${{ steps.cp310.outputs.python-path }}' nox --version + run: pipx run --python '${{ steps.cp310.outputs.python-path }}' nox --version \ No newline at end of file diff --git a/.github/workflows/licensed.yml b/.github/workflows/licensed.yml index 6f4cd922..88d3eae6 100644 --- a/.github/workflows/licensed.yml +++ b/.github/workflows/licensed.yml @@ -9,21 +9,6 @@ on: - main jobs: - test: - runs-on: ubuntu-latest - name: Check licenses - steps: - - uses: actions/checkout@v3 - - name: Set Node.js 16.x - uses: actions/setup-node@v3 - with: - node-version: 16.x - cache: npm - - run: npm ci - - name: Install licensed - run: | - cd $RUNNER_TEMP - curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/3.4.4/licensed-3.4.4-linux-x64.tar.gz - sudo tar -xzf licensed.tar.gz - sudo mv licensed /usr/local/bin/licensed - - run: licensed status + call-licensed: + name: Licensed + uses: actions/reusable-workflows/.github/workflows/licensed.yml@main \ No newline at end of file diff --git a/.github/workflows/release-new-action-version.yml b/.github/workflows/release-new-action-version.yml index b8076d43..a28a50ce 100644 --- a/.github/workflows/release-new-action-version.yml +++ b/.github/workflows/release-new-action-version.yml @@ -1,4 +1,5 @@ name: Release new action version + on: release: types: [released] @@ -24,4 +25,4 @@ jobs: uses: actions/publish-action@v0.2.1 with: source-tag: ${{ env.TAG_NAME }} - slack-webhook: ${{ secrets.SLACK_WEBHOOK }} + slack-webhook: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.github/workflows/test-pypy.yml b/.github/workflows/test-pypy.yml index de9ba6b7..692cda66 100644 --- a/.github/workflows/test-pypy.yml +++ b/.github/workflows/test-pypy.yml @@ -1,4 +1,5 @@ name: Validate PyPy e2e + on: push: branches: diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 921449fb..37a17241 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -1,4 +1,5 @@ name: Validate Python e2e + on: push: branches: diff --git a/package.json b/package.json index 9f6c3d5d..b8bfb1ec 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build": "ncc build -o dist/setup src/setup-python.ts && ncc build -o dist/cache-save src/cache-save.ts", "format": "prettier --write \"{,!(node_modules)/**/}*.ts\"", "format-check": "prettier --check \"{,!(node_modules)/**/}*.ts\"", + "lint": "echo \"Fake command that does nothing. It is used in reusable workflows\"", "release": "ncc build -o dist/setup src/setup-python.ts && ncc build -o dist/cache-save src/cache-save.ts && git add -f dist/", "test": "jest --coverage" },