Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

11 configure cicd #13

Merged
merged 84 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
842e55a
add frontend
archeoss Aug 19, 2023
7a5dc02
update dev. paths for frontend + Update README
archeoss Aug 19, 2023
63e703f
migrate to astro
archeoss Aug 25, 2023
fc834b7
Create rust.yml
archeoss Sep 3, 2023
7284082
clippy
archeoss Sep 3, 2023
d4e19f4
add gen-openapi script
archeoss Sep 4, 2023
26e7f82
Create docker-image.yml
archeoss Sep 4, 2023
81c648e
Update rust.yml
archeoss Sep 4, 2023
97db57e
Update rust.yml
archeoss Sep 4, 2023
308d73d
update Cargo
archeoss Sep 4, 2023
e17970f
fix swagger-ui
archeoss Sep 4, 2023
cf5a869
Update rust.yml
archeoss Sep 4, 2023
b897a7a
Update rust.yml
archeoss Sep 4, 2023
6409909
Update API schema
github-actions[bot] Sep 4, 2023
52a5b1c
separate gen from CI
archeoss Sep 4, 2023
282f368
Update gen-openapi.yml
archeoss Sep 4, 2023
dc97906
Update gen-openapi.yml
archeoss Sep 4, 2023
091bd41
Update gen-openapi.yml
archeoss Sep 4, 2023
a2008de
Create api.yml
archeoss Sep 4, 2023
0ec4539
Update gen-openapi.yml
archeoss Sep 4, 2023
90b082c
continue on error
archeoss Sep 4, 2023
d639324
continue on error
archeoss Sep 5, 2023
5d5df8d
rebase + restucture
archeoss Sep 7, 2023
d2e95a2
Update API schema
github-actions[bot] Sep 7, 2023
e580204
fmt + clippy
archeoss Sep 7, 2023
6caef0a
fix docker ci
archeoss Sep 19, 2023
829aaf8
break down CI to diff jobs
archeoss Sep 19, 2023
db42409
fix uses repo
archeoss Sep 19, 2023
033d5c7
small fixes
archeoss Sep 19, 2023
84800d2
Autogenerate API
archeoss Sep 19, 2023
21f4758
add version tag
archeoss Sep 19, 2023
c12ede5
fix docker ci
archeoss Sep 19, 2023
d6c593b
change api-gen trigger
archeoss Sep 19, 2023
e01e396
fix docker build
archeoss Sep 19, 2023
0542bdf
add changelog workflow
archeoss Sep 19, 2023
656880d
post rebase fixes
archeoss Oct 3, 2023
1894eee
post rebase fixes
archeoss Oct 3, 2023
054ef61
fix gen_openapi
archeoss Oct 3, 2023
4597ba0
check gen_openapi trigger
archeoss Oct 3, 2023
01430f1
Autogenerate API
archeoss Oct 3, 2023
534fab4
gen_openapi tweaking
archeoss Oct 3, 2023
04e3ee5
gen_openapi tweaking
archeoss Oct 3, 2023
e475051
Autogenerate API
archeoss Oct 3, 2023
26f7b15
gen_openapi tweaking
archeoss Oct 3, 2023
98c8cff
gen_openapi tweaking
archeoss Oct 3, 2023
e6a536b
gen_openapi tweaking
archeoss Oct 3, 2023
920dd6f
fix genapi
archeoss Oct 3, 2023
02cc7d1
Autogenerate API
archeoss Oct 5, 2023
d98c324
clippy + FMT FIXES fixes
archeoss Oct 6, 2023
25e4d74
Autogenerate API
archeoss Oct 9, 2023
734c699
post rebase fix
archeoss Oct 9, 2023
dbe885a
remove json schema
archeoss Oct 12, 2023
99f5a6a
gen-openapi moved to utils
archeoss Nov 9, 2023
2057948
update test command
archeoss Nov 9, 2023
ca9afb9
rebase
archeoss Nov 9, 2023
0f6e4d0
build fix
archeoss Nov 13, 2023
496fd1b
build fix
archeoss Nov 13, 2023
e6efe9a
Autogenerate API
archeoss Nov 13, 2023
613edca
test fix
archeoss Nov 13, 2023
45530f1
Update gen-openapi.yml
ikopylov Nov 16, 2023
a928785
Update gen-openapi.yml
ikopylov Nov 16, 2023
d97b443
Test openAPI generation
ikopylov Nov 16, 2023
8f66ebd
Update gen-openapi.yml
ikopylov Nov 16, 2023
1558e4b
Autogenerate API
ikopylov Nov 16, 2023
05f5dac
Update gen-openapi.yml
ikopylov Nov 16, 2023
eb77c98
Check OpenAPI gen
ikopylov Nov 16, 2023
50c469b
Autogenerate API
ikopylov Nov 16, 2023
7fc9279
Update openapi.yaml
ikopylov Nov 16, 2023
b4e86f3
Update openapi.yaml
ikopylov Nov 16, 2023
fc74060
Autogenerate API
ikopylov Nov 16, 2023
4bdef80
post-review fixes
archeoss Nov 18, 2023
4b7d75a
fix checks
archeoss Nov 18, 2023
8f0c6bd
fix typo
archeoss Nov 18, 2023
206d810
Update .github/workflows/docker-image.yml
ikopylov Nov 18, 2023
5e14380
Check openapi.yaml generation
ikopylov Nov 18, 2023
cc424a6
Autogenerate API
ikopylov Nov 18, 2023
58e51de
add flags for release's dead code
archeoss Nov 21, 2023
7b5bfbc
fix fmt
archeoss Nov 21, 2023
09a9ce4
small tweaks
archeoss Nov 23, 2023
ab6c1ca
add frontend ci
archeoss Nov 27, 2023
ae467a5
ci fixup
archeoss Nov 27, 2023
b6c4b4c
add release build job
archeoss Dec 1, 2023
48d0255
minor fixes
archeoss Dec 17, 2023
ad10785
Update rust.yml
ikopylov Dec 20, 2023
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
15 changes: 15 additions & 0 deletions .github/workflows/changelog-updated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Changelog checker"
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]

jobs:
# Enforces the update of a changelog file on every pull request
changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dangoslen/changelog-enforcer@v2
with:
changeLogPath: "CHANGELOG.md"
skipLabels: "Skip-Changelog"
25 changes: 25 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: build-docker

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]

jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: Set Bob GUI version
run: echo "VERSION=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' --raw-output)" >> "$GITHUB_ENV"
- name: Build alpine image
uses: docker/build-push-action@v5
with:
ikopylov marked this conversation as resolved.
Show resolved Hide resolved
context: .
file: dockerfiles/alpine/Dockerfile
tags: bob-management-gui:${{ env.VERSION }}
build-args: |
GIT_HASH_VAR=${{ github.sha }}
BRANCH_TAG_VAR=${{ github.ref }}
71 changes: 71 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CI frontend

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
push:
branches: [main]

jobs:
build-frontend-with-yarn:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install
dir: frontend
- name: Build frontend
uses: borales/actions-yarn@v4
with:
cmd: build
dir: frontend
lint-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install
dir: frontend
- name: Lint frontend
uses: borales/actions-yarn@v4
with:
cmd: lint
dir: frontend
test-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install
dir: frontend
- name: Install Playwright Browsers
uses: borales/actions-yarn@v4
with:
cmd: playwright install --with-deps
dir: frontend
- name: Run Playwright tests
uses: borales/actions-yarn@v4
with:
cmd: playwright test
dir: frontend
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: frontend/playwright-report/
retention-days: 30
29 changes: 29 additions & 0 deletions .github/workflows/gen-openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: update-api-schema

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]

jobs:
gen-openapi:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.QOOLLO_BOT_APP_ID }}
private-key: ${{ secrets.QOOLLO_BOT_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ steps.app-token.outputs.token }}
- uses: actions-rs/cargo@v1
with:
command: run
args: -p utils --bin gen-openapi -- -f api/openapi.yaml
- name: "Update API schema"
archeoss marked this conversation as resolved.
Show resolved Hide resolved
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_user_name: "qoollo-bot[bot]"
commit_user_email: "151071968+qoollo-bot[bot]@users.noreply.github.com"
commit_message: "Autogenerate API"
54 changes: 54 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI backend

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
push:
branches: [main]

env:
CARGO_TERM_COLOR: always

jobs:
build-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo build-backend
build-backend-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo build-backend --profile=release-lto
build-frontend-with-cargo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo build-frontend
build-all:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo build
test-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test
fmt-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo clippy
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Bob Management GUI changelog
- Initial project structure, backend only (#9)
- Initial project stricture, frontend (#10)
- Dockerfile and Docker-Compose to simplify deployment (#5)
- CI/CD configuration (#11)
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license-file = "./LICENSE"
edition = "2021"

[workspace]
members = [ "cli", "frontend", "backend" ]
members = [ "cli", "frontend", "backend", "utils" ]
default-members = [ "frontend", "backend"]
resolver = "2"

Expand Down
Empty file added api/.gitkeep
Empty file.
21 changes: 21 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
openapi: 3.0.3
info:
title: bob-management
description: 'Bob Management GUI: Backend'
contact:
name: Romanov Simeon [email protected]
license:
name: ''
version: 0.0.0
paths:
/root:
get:
tags:
- crate
operationId: root
responses:
'200':
description: Hello Bob!
tags:
- name: bob
description: BOB management API
1 change: 1 addition & 0 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ cli = { path = "../cli" }
[features]
default = [ "swagger" ]
swagger = [ "dep:utoipa", "dep:utoipa-swagger-ui" , "dep:utoipa-redoc", "dep:utoipa-rapidoc" ]
gen_api = [ "dep:utoipa" ]
1 change: 0 additions & 1 deletion backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub struct ApiDoc;
pub async fn root() -> &'static str {
"Hello Bob!"
}

/// Generate openapi documentation for the project
#[cfg(all(feature = "swagger", debug_assertions))]
pub fn openapi_doc() -> Router {
Expand Down
1 change: 1 addition & 0 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fn init_tracer(_log_file: &Option<PathBuf>, trace_level: Level) {
subscriber.init();
}

#[allow(clippy::unwrap_used, clippy::expect_used)]
fn router(cors: CorsLayer) -> Router {
let mut frontend = env::current_exe().expect("Couldn't get current executable path.");
frontend.pop();
Expand Down
5 changes: 4 additions & 1 deletion backend/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ use std::convert::Infallible;
use std::marker::PhantomData;
use std::ops::Deref;
use thiserror::Error;
use utoipa::openapi::PathItemType;
use utoipa::OpenApi;

#[cfg(all(feature = "swagger", debug_assertions))]
use utoipa::openapi::PathItemType;

#[derive(Clone, Debug, Error, PartialEq, Eq, PartialOrd, Ord)]
pub enum RouteError {
#[error("No route found in OpenAPI scheme")]
Expand Down Expand Up @@ -209,6 +211,7 @@ where
.attach_printable_lazy(|| format!("route: {route}"))
}

#[cfg(all(feature = "swagger", debug_assertions))]
fn try_convert_path_item_type_from_method(value: &Method) -> Result<PathItemType, RouteError> {
Ok(match *value {
Method::GET => PathItemType::Get,
Expand Down
1 change: 0 additions & 1 deletion cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ mod config;
pub use clap::Parser;
pub use cli::Args;
pub use config::{Config, FromFile, LoggerConfig};

14 changes: 9 additions & 5 deletions dockerfiles/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ RUN echo "$(case "$BUILD_PROFILE" in\
(*) echo "$BUILD_PROFILE";;\
esac)" >> ./build_profile_dir

RUN mkdir -p backend/src frontend cli/src
RUN mkdir -p backend/src frontend cli/src utils/src
RUN mkdir target
COPY Cargo.toml Cargo.toml
COPY cli/Cargo.toml cli/Cargo.toml
COPY backend/Cargo.toml backend/Cargo.toml
COPY utils/Cargo.toml utils/Cargo.toml
COPY frontend/Cargo.toml frontend/Cargo.toml
COPY .cargo .cargo
RUN echo "fn main() {println!(\"if you see this, the build broke\")}" > backend/src/lib.rs \
RUN echo "// if you see this, the build broke" > backend/src/lib.rs \
&& echo "fn main() {println!(\"if you see this, the build broke\")}" > backend/src/main.rs \
&& echo "fn main() {println!(\"if you see this, the build broke\")}" > frontend/build.rs \
&& echo "fn main() {println!(\"if you see this, the build broke\")}" > cli/src/lib.rs \
&& echo "fn main() {println!(\"if you see this, the build broke\")}" > build.rs \
&& echo "// if you see this, the build broke" > cli/src/lib.rs \
&& cargo build-backend --profile=$BUILD_PROFILE --target=$BUILD_TARGET

COPY . ./
Expand All @@ -50,7 +50,11 @@ FROM node:20.6 as frontend

COPY ./frontend ./frontend

RUN cd frontend && yarn && yarn build && mkdir /build_output && cp -r ./frontend /build_output/frontend
RUN cd frontend \
&& yarn \
&& yarn build \
&& mkdir /build_output \
&& cp -r ./frontend /build_output/frontend

FROM alpine:3.18
ARG APP=/home/bob-management
Expand Down
4 changes: 4 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ pnpm-debug.log*

# macOS-specific files
.DS_Store
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
16 changes: 9 additions & 7 deletions frontend/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ fn shell(command: impl AsRef<OsStr> + Display) {
.arg(SHELL_ARG)
.arg(&command)
.output()
.expect(format!("Failed to run {cmd}", cmd = command).as_str());
.unwrap_or_else(|_| panic!("Failed to run {cmd}", cmd = command));

// println!("build.rs => {:?}", output.stdout);
let mut file = File::create("build.log").expect("Couldn't create log file...");
file.write(b"build log\n\n\n\nSTDOUT:\n")
let mut file = File::create("build.log").expect("Couldn't create file...");
file.write_all(b"build log\n\n\n\nSTDOUT:\n")
.expect("Couldn't write to build log");
file.write_all(&output.stdout)
.expect("Couldn't write to build log");
file.write(b"\n\n\n\nSTDERR:\n")
file.write_all(b"\n\n\n\nSTDERR:\n")
.expect("Couldn't write to build log");
file.write_all(&output.stderr)
.expect("Couldn't write to build log");
Expand Down Expand Up @@ -89,11 +89,13 @@ pub fn move_frontend() {
.append(true)
.open("build.log")
.expect("Couldn't open log file...");
file.write(format!("PROJECT DIR: {project_dir:?}\n").as_bytes())
file.write_all(format!("PROJECT DIR: {project_dir:?}\n").as_bytes())
.expect("Couldn't write to build log");

file.write(format!("Moving /{FRONTEND_DIR} from {project_dir:?} to: {target:?}\n").as_bytes())
.expect("Couldn't write to build log");
file.write_all(
format!("Moving /{FRONTEND_DIR} from {project_dir:?} to: {target:?}\n").as_bytes(),
)
.expect("Couldn't write to build log");

copy_dir_all(project_dir, target).expect("Couldn't move frontend build artifacts");
}
Expand Down
18 changes: 18 additions & 0 deletions frontend/e2e/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { test, expect } from '@playwright/test';

test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
});

test('get started link', async ({ page }) => {
await page.goto('https://playwright.dev/');

// Click the get started link.
await page.getByRole('link', { name: 'Get started' }).click();

// Expects page to have a heading with the name of Installation.
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});
1 change: 1 addition & 0 deletions frontend/frontend.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading
Loading