Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# *.fsx,*.fs: formatting F# files using fantomless
df5cfb143c4efe73806ead91e5cddf4e133be0a8

# commitlint.config: split helper funcs and plugins
3008d6578aa484ae776b29c9246dca4eeae3418a

Expand Down
119 changes: 0 additions & 119 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,99 +3,8 @@ 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:
- file-conventions-tests
- commitlint-plugins-tests
runs-on: ubuntu-22.04
container:
image: "ubuntu:22.04"
Expand Down Expand Up @@ -129,37 +38,9 @@ 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 code
run: |
sudo npx prettier --quote-props=consistent --write './**/*.ts'
# 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
Expand Down
80 changes: 80 additions & 0 deletions WorkflowGuidelines.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,84 @@
# Workflow guidelines

* Avoid typical bad practices like:

* Magic numbers:

Avoid using unnamed numerical constants in software code, this practice makes code hard to understand and maintain.

Example:
```
var distance = GpsUtil.GetDistance()
if (distance < 100)
throw new NotImplementedException();
```
```
private const int MinimumSupportedDistanceToNotifyKillerDrones = 100;

...

var distance = GpsUtil.GetDistance()
if (distance < MinimumSupportedDistanceToNotifyKillerDrones)
throw new NotImplementedException();
```

* DRY (Don't Repeat Yourself):

The DRY principle suggests that a piece of information should only be stored once in a project and should be referenced as needed, rather than being copied and pasted multiple times throughout the codebase.

It has several benefits, including reducing the amount of code that needs to be written and maintained, improving the consistency and quality of the code, and reducing the risk of introducing errors and bugs when the information changes.

Example:
```
let preAuthInputMac =
CalculateMacWithSHA3256
preAuthInput
":hs_mac"

...

let authInputMac =
CalculateMacWithSHA3256
authInput
":hs_mac"
```
```
let AuthenticationDigestCalculationKey = ":hs_mac"

...

let preAuthInputMac =
CalculateMacWithSHA3256
preAuthInput
AuthenticationDigestCalculationKey

...

let authInputMac =
CalculateMacWithSHA3256
authInput
AuthenticationDigestCalculationKey
```

* Primitive Obsession:

Primitive Obsession is a situation where simple data types such as strings, integers, or arrays are overused in place of more appropriate objects.

Example:
```
let saveFilePath = System.Console.ReadLine()

let savedData = System.IO.File.ReadAllText saveFilePath
```
```
let saveFilePath =
let saveFilePathInString =
System.Console.ReadLine()
System.IO.FileInfo saveFilePathInString

let savedData = System.IO.File.ReadAllText saveFilePath.FullName
```

* When contributing a PullRequest, separate your commits in units of work
(don't mix changes that have different concerns in the same commit). Don't
forget to include all explanations and reasonings in the commit messages,
Expand Down Expand Up @@ -75,3 +154,4 @@ closed after the commit lands, then you would use the word `Closes` instead of
Do not use long lines (manually crop them with EOLs because git doesn't do this
automatically).


Loading