From 4908bd783adca45df73dd1dcc731983b169c22a2 Mon Sep 17 00:00:00 2001 From: realmarv Date: Wed, 17 May 2023 10:11:26 +0330 Subject: [PATCH 1/2] scripts/detectNotUsingGitPush1by1.fsx: improve Lacking CI status may be because of not enabling GitHub Actions or not pushing the commits 1 by 1. The purpose of this commit is to address these situations separately and display distinct commit messages based on each scenario. --- scripts/detectNotUsingGitPush1by1.fsx | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/detectNotUsingGitPush1by1.fsx b/scripts/detectNotUsingGitPush1by1.fsx index 9bebfb65..e423b577 100644 --- a/scripts/detectNotUsingGitPush1by1.fsx +++ b/scripts/detectNotUsingGitPush1by1.fsx @@ -802,7 +802,7 @@ let prCommits = let parsedPrCommitsJsonObj = PRCommitsType.Parse prCommitsJsonString parsedPrCommitsJsonObj |> Seq.map(fun commit -> commit.Sha) -let notUsingGitPush1by1 = +let hasCiStatus = prCommits |> Seq.map(fun commit -> @@ -814,11 +814,27 @@ let notUsingGitPush1by1 = let json = GitHubApiCall url - json.Contains "\"check_suites\":[]" + not(json.Contains "\"check_suites\":[]") ) - |> Seq.contains true -if notUsingGitPush1by1 then +let gitHubActionsEnabled = Seq.contains true hasCiStatus + +if not gitHubActionsEnabled then + let errMsg = + sprintf + """ +Please activate GitHub Actions in your repository. Click on the +"Actions" tab at the top of the repository page and click on the +"I understand my workflows, go ahead and enable them" button. +""" + + Console.Error.WriteLine errMsg + Environment.Exit 1 + +let notUsedGitPush1by1 = + gitHubActionsEnabled && Seq.contains false hasCiStatus + +if notUsedGitPush1by1 then let errMsg = sprintf "Please push the commits one by one; using this script is recommended:%s%s" @@ -826,4 +842,4 @@ if notUsingGitPush1by1 then "https://github.com/nblockchain/conventions/blob/master/scripts/gitPush1by1.fsx" Console.Error.WriteLine errMsg - Environment.Exit 1 + Environment.Exit 2 From 556a7acd3ff9ec035269ded3566989e7cf815046 Mon Sep 17 00:00:00 2001 From: realmarv Date: Wed, 17 May 2023 13:09:43 +0330 Subject: [PATCH 2/2] wip1 --- .github/workflows/CI.yml | 133 --------------------------------------- 1 file changed, 133 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index efd23b7f..dda8b72a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -3,94 +3,6 @@ name: CI on: [push, pull_request] jobs: - build: - name: Build - runs-on: ubuntu-22.04 - container: - image: "ubuntu:22.04" - steps: - - uses: actions/checkout@v2 - - name: Install required dependencies - run: | - apt update - apt install -y sudo - sudo apt install -y git - # workaround for https://github.com/actions/runner/issues/2033 - - name: ownership workaround - run: git config --global --add safe.directory '*' - - name: Install dotnet sdk - run: sudo apt install -y dotnet6 - - name: Compile the conventions solution - run: dotnet build --configuration Release conventions.sln - - name: Compile F# scripts - run: dotnet fsi scripts/compileFSharpScripts.fsx - - file-conventions-tests: - name: Run FileConventions-lib unit tests - needs: build - runs-on: ubuntu-22.04 - container: - image: "ubuntu:22.04" - steps: - - uses: actions/checkout@v2 - - name: Install required dependencies - run: | - apt update - apt install --yes sudo - - # We need to install curl otherwise we get these errors in the CI: - # Unable to load the service index for source https://api.nuget.org/v3/index.json. - # The SSL connection could not be established, see inner exception. - # The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot - sudo apt install --yes curl - - - name: Setup .NET - run: apt install -y dotnet6 - - name: Run tests to validate F# scripts - run: dotnet test src/FileConventions.Test/FileConventions.Test.fsproj - - commitlint-plugins-tests: - name: Run commitlint-related tests - needs: build - runs-on: ubuntu-22.04 - container: - image: "ubuntu:22.04" - steps: - - uses: actions/checkout@v2 - - name: Install required dependencies - run: | - apt update - apt install --yes sudo - sudo apt install --yes git - - sudo apt install --yes curl - # can't install ubuntu's default nodejs version because we would get this error: - # error @jest/core@29.4.1: The engine "node" is incompatible with this module. Expected version "^14.15.0 || ^16.10.0 || >=18.0.0". Got "12.22.9" - curl --show-error --location https://deb.nodesource.com/setup_14.x | sudo --preserve-env bash - - sudo DEBIAN_FRONTEND=noninteractive apt install --yes nodejs - - name: Print versions - run: | - git --version - node --version - npm --version - npx commitlint --version - - name: Install yarn - run: | - npm install --global yarn - yarn add --dev jest typescript ts-jest @types/jest - - name: Install commitlint - run: | - npm install conventional-changelog-conventionalcommits - npm install commitlint@latest - - name: Print versions - run: | - git --version - node --version - npm --version - npx commitlint --version - - name: Run tests to validate our plugins - run: yarn jest - sanity-check: name: Sanity check needs: @@ -104,7 +16,6 @@ jobs: run: | apt update && apt install --yes sudo sudo apt install --yes git - sudo DEBIAN_FRONTEND=noninteractive apt install --yes npm - uses: actions/checkout@v2 with: submodules: recursive @@ -113,15 +24,6 @@ jobs: # workaround for https://github.com/actions/runner/issues/2033 - name: ownership workaround run: git config --global --add safe.directory '*' - - name: Print versions - run: | - git --version - node --version - npm --version - - name: Validate current commit (last commit) with commitlint - if: github.event_name == 'push' - run: ./commitlint.sh --from HEAD~1 --to HEAD --verbose - - name: Validate PR commits with commitlint if: github.event_name == 'pull_request' run: | ./commitlint.sh --verbose \ @@ -129,41 +31,6 @@ jobs: --to ${{ github.event.pull_request.head.sha }} - name: Install dotnet sdk run: sudo apt install --yes dotnet6 - - name: Check all files end with EOL - run: dotnet fsi scripts/eofConvention.fsx - - name: Check all .fsx scripts have shebang - run: dotnet fsi scripts/shebangConvention.fsx - - name: Check there are no mixed line-endings in any files - run: dotnet fsi scripts/mixedLineEndings.fsx - - name: Check there are no unpinned GitHubActions image versions - run: dotnet fsi scripts/unpinnedGitHubActionsImageVersions.fsx - - name: Check there are no unpinned dotnet package versions - run: dotnet fsi scripts/unpinnedDotnetPackageVersions.fsx - - name: Check there are no unpinned nuget package reference versions in F# scripts - run: dotnet fsi scripts/unpinnedNugetPackageReferenceVersions.fsx - name: Check if gitPush1by1 was used if: github.event_name == 'pull_request' run: dotnet fsi scripts/detectNotUsingGitPush1by1.fsx - - name: Install prettier - run: npm install prettier@2.8.3 - - name: Change file permissions - # We need this step so we can change the files using `npx prettier --write` in the next step. - # Otherwise we get permission denied error in the CI. - run: sudo chmod 777 -R . - - name: Run "prettier" to check the style of our TypeScript and YML code - run: | - sudo npx prettier --quote-props=consistent --write './**/*.ts' - sudo npx prettier --quote-props=consistent --write './**/*.yml' - # Since we changed file modes in the previous step we need the following command to - # make git ignore mode changes in files and doesn't include them in the git diff command. - git config core.fileMode false - # Since after installing commitlint dependencies package.json file changes, we need to - # run the following command to ignore package.json file - git restore package.json - git diff --exit-code - - name: fantomless - run: | - dotnet new tool-manifest - dotnet tool install fantomless-tool --version 4.7.997-prerelease - dotnet fantomless --recurse . - git diff --exit-code