Skip to content

CI

CI #2988

Workflow file for this run

name: CI
on:
push:
pull_request:
workflow_dispatch:
# see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
schedule:
- cron: "0 0 * * *"
env:
DOTNET_VERSION: "8.0"
# As we use .NET>6 now, to run tools compiled for .NETv6 we need to set roll-forward to major
DOTNET_ROLL_FORWARD: Major
TYPESCRIPT_VERSION: "5.8.3"
CHECKOUT_ACTION_VERSION: "4"
jobs:
build-fs:
name: Build F#
runs-on: ubuntu-24.04
container:
image: "ubuntu:24.04"
steps:
- name: Run actions/checkout
uses: nblockchain/conventions@master
with:
uses: actions/checkout@v${{ env.CHECKOUT_ACTION_VERSION }}
- name: Install required dependencies
run: |
apt update
apt install --yes sudo
sudo apt install --yes --no-install-recommends git
- name: Setup .NET
run: |
# We need to install `ca-certificates`, 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
apt install --yes --no-install-recommends ca-certificates
apt install --yes --no-install-recommends dotnet-sdk-${{ env.DOTNET_VERSION }}
- 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-fs
runs-on: ubuntu-24.04
container:
image: "ubuntu:24.04"
steps:
- name: Run actions/checkout
uses: nblockchain/conventions@master
with:
uses: actions/checkout@v${{ env.CHECKOUT_ACTION_VERSION }}
- name: Install required dependencies
run: |
apt update
apt install --yes sudo
- name: Setup .NET
run: |
# We need to install `ca-certificates`, 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
apt install --yes --no-install-recommends ca-certificates
apt install --yes --no-install-recommends dotnet-sdk-${{ env.DOTNET_VERSION }}
- name: Run tests to validate F# scripts
run: dotnet test src/FileConventions.Test/FileConventions.Test.fsproj
build-ts:
name: Build TypeScript
runs-on: ubuntu-24.04
container:
image: "ubuntu:24.04"
steps:
- name: Run actions/checkout
uses: nblockchain/conventions@master
with:
uses: actions/checkout@v${{ env.CHECKOUT_ACTION_VERSION }}
- name: Install required dependencies
run: |
apt update
apt install --yes sudo
sudo apt install --yes --no-install-recommends git ca-certificates
sudo apt install --yes --no-install-recommends npm curl
- name: Print versions
run: |
git --version
node --version
npm --version
- name: Install yarn and yarn modules
run: |
npm install --verbose --global yarn
yarn add --dev typescript@$TYPESCRIPT_VERSION eslint @eslint/js typescript-eslint
- name: Install commitlint dependencies
run: |
. commitlint/version.config
npm install --verbose @commitlint/types@$COMMITLINT_VERSION
- name: Print versions
run: |
git --version
node --version
npm --version
- name: Run typescript compiler
run: npx tsc
- name: Run typescript-eslint
run: npx eslint .
commitlint-plugins-tests:
name: Run commitlint-related tests
needs: build-ts
runs-on: ubuntu-24.04
container:
image: "ubuntu:24.04"
steps:
- name: Run actions/checkout
uses: nblockchain/conventions@master
with:
uses: actions/checkout@v${{ env.CHECKOUT_ACTION_VERSION }}
- name: Install required dependencies
run: |
apt update
apt install --yes sudo
sudo apt install --yes --no-install-recommends git ca-certificates
sudo apt install --yes --no-install-recommends npm curl
- name: Install yarn and yarn modules
run: |
npm install --verbose --global yarn
yarn add --dev typescript@$TYPESCRIPT_VERSION ts-node
- name: Install commitlint dependencies
run: |
. commitlint/version.config
npm install --verbose @commitlint/types@$COMMITLINT_VERSION
- name: Run typescript compiler
run: npx tsc
- name: Print versions
run: |
git --version
node --version
npm --version
yarn --version
npx tsc --version
- name: Install commitlint
run: ./commitlint.sh --version
- name: Run tests to validate our plugins
run: |
# remove *.js files so that the same tests don't run twice
rm ./commitlint/tests/*.js
yarn test
sanity-check:
name: Sanity check
needs:
- file-conventions-tests
- commitlint-plugins-tests
runs-on: ubuntu-24.04
container:
image: "ubuntu:24.04"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Install required dependencies
run: |
apt update && apt install --yes sudo
# otherwise it gives error "Error: Input 'submodules' not supported when falling back to download using the GitHub REST API. To create a local Git repository instead, add Git 2.18 or higher to the PATH."
sudo apt install --yes --no-install-recommends git
# otherwise it gives error "fatal: unable to access 'https://github.com/nblockchain/conventions/': server certificate verification failed. CAfile: none CRLfile: none"
sudo apt install --yes --no-install-recommends ca-certificates
- name: Run actions/checkout
uses: nblockchain/conventions@master
with:
uses: actions/checkout@v${{ env.CHECKOUT_ACTION_VERSION }}
with: |
{
"submodules": "recursive",
"fetch-depth": 0
}
- name: Setup .NET
run: |
# We need to install `ca-certificates`, 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
apt install --yes --no-install-recommends ca-certificates
apt install --yes --no-install-recommends dotnet-sdk-${{ env.DOTNET_VERSION }}
- 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 all F# scripts have execute permission
run: dotnet fsi scripts/executableConvention.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 nuget package reference versions in .NET project files
run: dotnet fsi scripts/unpinnedNugetPackageReferenceVersionsInProjects.fsx
- name: Check there are no unpinned nuget package reference versions in F# scripts
run: dotnet fsi scripts/unpinnedNugetPackageReferenceVersionsInFSharpScripts.fsx
- name: Check there are no unpinned versions in `dotnet tool install` commands
run: dotnet fsi scripts/unpinnedDotnetToolInstallVersions.fsx
- name: Check there are no inconsistent versions GitHubCI files
run: dotnet fsi scripts/inconsistentVersionsInGitHubCI.fsx
- name: Check there are no inconsistent versions in nuget package references of F# scripts
run: dotnet fsi scripts/inconsistentNugetVersionsInFSharpScripts.fsx
- name: Check there are no non-verbose flags in scripts and CI YML files
run: dotnet fsi scripts/nonVerboseFlagsInGitHubCIAndScripts.fsx
- name: Sanity check nuget packages of .NET projects
run: |
dotnet restore
dotnet fsi scripts/inconsistentNugetVersionsInDotNetProjects.fsx
- name: Check there are no inconsistent versions in nuget package references of F# scripts and projects
run: dotnet fsi scripts/inconsistentNugetVersionsInDotNetProjectsAndFSharpScripts.fsx
- name: FSharpLint
run: |
dotnet fsi scripts/runFSharpLint.fsx
- name: Run git+githubCI workaround
run: |
# workaround for https://github.com/actions/runner/issues/2033
git config --global --add safe.directory '*'
- name: fantomless
run: |
dotnet tool install fantomless-tool --version 4.7.997-prerelease
dotnet fantomless --recurse .
git diff --exit-code
- name: Check commits 1 by 1
if: github.event_name == 'pull_request'
run: dotnet fsi scripts/checkCommits1by1.fsx
- name: Install commitlint&prettier's required dependencies
run: |
sudo apt install --yes --no-install-recommends npm
- name: Print versions
run: |
git --version
node --version
npm --version
- name: Run git+githubCI workaround
run: |
# 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.
sudo chmod 777 --recursive .
- name: Install prettier
run: npm install --verbose [email protected]
- 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: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: ./commitlint.sh --last --verbose
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: |
./commitlint.sh --verbose \
--from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} \
--to ${{ github.event.pull_request.head.sha }}