-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: adding Continuous integration (CI) workflow
- Loading branch information
1 parent
0e64a8f
commit 1e9d289
Showing
19 changed files
with
295 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Continuous Integration (CI) | ||
|
||
on: pull_request | ||
|
||
env: | ||
# Forcing Earthly to use colours, to make reading output easier. | ||
FORCE_COLOR: 1 | ||
|
||
jobs: | ||
formatting: | ||
name: Formatting | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
language: [rust, python, shell, yaml] | ||
steps: | ||
- name: Download Earthly v0.8.12. | ||
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.12/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" | ||
- name: Checkout code. | ||
uses: actions/checkout@v3 | ||
- name: Check formatting. | ||
run: earthly --ci +check-${{ matrix.language }}-formatting | ||
linting: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
language: [rust, shell] | ||
steps: | ||
- name: Download Earthly v0.8.12. | ||
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.12/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" | ||
- name: Checkout code. | ||
uses: actions/checkout@v3 | ||
- name: Check linting. | ||
run: earthly --ci +check-${{ matrix.language }}-linting | ||
compile: | ||
name: Compile | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download Earthly v0.8.12. | ||
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.12/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" | ||
- name: Checkout code. | ||
uses: actions/checkout@v3 | ||
- name: Compile. | ||
run: earthly --ci +compile | ||
unit-test: | ||
name: Unit Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download Earthly v0.8.12. | ||
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.12/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" | ||
- name: Checkout code. | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
fetch-depth: 0 | ||
- name: Unit test. | ||
run: earthly --ci +unit-test | ||
end-to-end-test: | ||
name: End to End Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download Earthly v0.8.12. | ||
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.8.12/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'" | ||
- name: Checkout code. | ||
uses: actions/checkout@v3 | ||
- name: End to End test. | ||
run: earthly --ci +end-to-end-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
formatter: | ||
type: basic | ||
retain_line_breaks: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,9 @@ COPY_METADATA: | |
|
||
|
||
rust-base: | ||
FROM rust:1.70.0 | ||
FROM rust:1.70.0-alpine3.18 | ||
RUN apk add --no-cache musl-dev bash | ||
WORKDIR "/conventional_commits_linter" | ||
|
||
|
||
check-clean-git-history: | ||
|
@@ -32,12 +34,125 @@ check-conventional-commits-linting: | |
RUN ./ci/check-conventional-commits-linting.sh --from-reference "${from_reference}" | ||
|
||
|
||
COPY_SOURCECODE: | ||
COMMAND | ||
DO +COPY_CI_DATA | ||
COPY --if-exists "Cargo.lock" "./" | ||
COPY --dir "Cargo.toml" "conventional_commits_linter/" "conventional_commits_linter_lib/" "./" | ||
|
||
|
||
rust-formatting-base: | ||
FROM +rust-base | ||
RUN rustup component add rustfmt | ||
DO +COPY_SOURCECODE | ||
|
||
|
||
check-rust-formatting: | ||
FROM +rust-formatting-base | ||
RUN ./ci/check-rust-formatting.sh | ||
|
||
|
||
python-base: | ||
FROM python:3.9.19-alpine | ||
RUN apk add --no-cache git bash | ||
WORKDIR "/consistent_whitespace" | ||
DO +COPY_SOURCECODE | ||
|
||
|
||
python-formatting-base: | ||
FROM +python-base | ||
RUN pip3 install -r "conventional_commits_linter/end-to-end-tests/autopep8.requirements.txt" | ||
|
||
|
||
check-python-formatting: | ||
FROM +python-formatting-base | ||
RUN ./ci/check-python-formatting.sh | ||
|
||
|
||
golang-base: | ||
FROM golang:1.22.1 | ||
ENV GOPROXY=direct | ||
ENV CGO_ENABLED=0 | ||
ENV GOOS=linux | ||
ENV GOARCH=amd64 | ||
WORKDIR "/consistent_whitespace" | ||
|
||
|
||
shell-formatting-base: | ||
FROM +golang-base | ||
RUN go install mvdan.cc/sh/v3/cmd/[email protected] | ||
DO +COPY_CI_DATA | ||
|
||
|
||
check-shell-formatting: | ||
FROM +shell-formatting-base | ||
RUN ./ci/check-shell-formatting.sh | ||
|
||
|
||
yaml-formatting-base: | ||
FROM +golang-base | ||
RUN go install github.com/google/yamlfmt/cmd/[email protected] | ||
COPY ".yamlfmt" "./" | ||
DO +COPY_CI_DATA | ||
|
||
|
||
check-yaml-formatting: | ||
FROM +yaml-formatting-base | ||
RUN ./ci/check-yaml-formatting.sh | ||
|
||
|
||
check-formatting: | ||
BUILD +check-rust-formatting | ||
BUILD +check-python-formatting | ||
BUILD +check-shell-formatting | ||
BUILD +check-yaml-formatting | ||
|
||
|
||
fix-rust-formatting: | ||
FROM +rust-formatting-base | ||
RUN ./ci/fix-rust-formatting.sh | ||
SAVE ARTIFACT "src/" AS LOCAL "./" | ||
|
||
|
||
fix-python-formatting: | ||
FROM +python-formatting-base | ||
RUN ./ci/fix-python-formatting.sh | ||
SAVE ARTIFACT "end-to-end-tests/" AS LOCAL "./" | ||
|
||
|
||
fix-shell-formatting: | ||
FROM +shell-formatting-base | ||
RUN ./ci/fix-shell-formatting.sh | ||
SAVE ARTIFACT "ci/" AS LOCAL "./" | ||
|
||
|
||
fix-yaml-formatting: | ||
FROM +yaml-formatting-base | ||
RUN ./ci/fix-yaml-formatting.sh | ||
SAVE ARTIFACT ".github/" AS LOCAL "./" | ||
|
||
|
||
fix-formatting: | ||
BUILD +fix-rust-formatting | ||
BUILD +fix-python-formatting | ||
BUILD +fix-shell-formatting | ||
BUILD +fix-yaml-formatting | ||
|
||
|
||
check-rust-linting: | ||
FROM +rust-base | ||
RUN rustup component add clippy | ||
DO +COPY_SOURCECODE | ||
RUN ./ci/check-rust-linting.sh | ||
|
||
|
||
ubuntu-base: | ||
FROM ubuntu:22.04 | ||
# https://askubuntu.com/questions/462690/what-does-apt-get-fix-missing-do-and-when-is-it-useful | ||
RUN apt-get update --fix-missing | ||
|
||
|
||
check-shell-linting: | ||
FROM +ubuntu-base | ||
RUN apt-get install shellcheck -y | ||
DO +COPY_CI_DATA | ||
RUN ./ci/check-shell-linting.sh | ||
|
||
|
||
check-github-actions-workflows-linting: | ||
|
@@ -48,22 +163,28 @@ check-github-actions-workflows-linting: | |
|
||
|
||
check-linting: | ||
BUILD +check-rust-linting | ||
BUILD +check-shell-linting | ||
BUILD +check-github-actions-workflows-linting | ||
|
||
|
||
e2e-formatting-base: | ||
FROM python:3.12.0-slim | ||
COPY "./ci" "./ci" | ||
COPY "./conventional_commits_linter/end-to-end-tests" "./conventional_commits_linter/end-to-end-tests" | ||
RUN pip3 install -r "./conventional_commits_linter/end-to-end-tests/autopep8.requirements.txt" | ||
compile: | ||
FROM +rust-base | ||
DO +COPY_SOURCECODE | ||
RUN ./ci/compile.sh | ||
SAVE ARTIFACT "target/" AS LOCAL "./" | ||
SAVE ARTIFACT "Cargo.lock" AS LOCAL "./" | ||
|
||
|
||
check-e2e-formatting: | ||
FROM +e2e-formatting-base | ||
RUN ./ci/check-e2e-formatting.sh | ||
unit-test: | ||
FROM +rust-base | ||
DO +COPY_METADATA | ||
DO +COPY_SOURCECODE | ||
RUN ./ci/unit-test.sh | ||
|
||
|
||
fix-e2e-formatting: | ||
FROM +e2e-formatting-base | ||
RUN ./ci/fix-e2e-formatting.sh | ||
SAVE ARTIFACT "./conventional_commits_linter/end-to-end-tests" AS LOCAL "./conventional_commits_linter/end-to-end-tests" | ||
end-to-end-test: | ||
FROM +python-base | ||
RUN pip3 install -r "conventional_commits_linter/end-to-end-tests/requirements.txt" | ||
COPY "+compile/target/" "target/" | ||
RUN ./ci/end-to-end-test.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
find "conventional_commits_linter/end-to-end-tests/features/" -type f | grep "[.]py$" | xargs -I {} autopep8 --exit-code --diff --aggressive --aggressive --max-line-length 120 "{}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
cargo fmt --all -- --check --config=group_imports=StdExternalCrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
cargo clippy --verbose --workspace --all-targets -- -D warnings | ||
cargo clippy --verbose --workspace --all-targets --all-features -- -D warnings | ||
cargo clippy --verbose --workspace --all-targets --no-default-features -- -D warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
shfmt --simplify --diff ./ci/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
shellcheck ci/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
yamlfmt -lint -dstar .github/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
cargo build --verbose --workspace | ||
cargo build --verbose --workspace --all-features | ||
cargo build --verbose --workspace --no-default-features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
cd "conventional_commits_linter/end-to-end-tests/" | ||
behave |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
find "conventional_commits_linter/end-to-end-tests/features/" -type f | grep "[.]py$" | xargs -I {} autopep8 --in-place --aggressive --aggressive --max-line-length 120 "{}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
cargo fmt --all -- --config=group_imports=StdExternalCrate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
shfmt --simplify --write ./ci/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
yamlfmt -dstar ./github/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -o errexit | ||
set -o xtrace | ||
|
||
cargo test --verbose --workspace | ||
cargo test --verbose --workspace --all-features | ||
cargo test --verbose --workspace --no-default-features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters