Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ff3d17d
refactor(SeleniumGridNodeAutoOldMachineDestroyer): reduce method leng…
vimscientist69 Sep 29, 2025
752cd5d
perf(WebsiteHTMLGetter): improve speed of browser startup and navigat…
vimscientist69 Sep 29, 2025
53f9854
fix(Dockerfile): set github token to be able to clone private reposit…
vimscientist69 Sep 29, 2025
41eda8c
feat(APIController): created api controller, routes without implement…
vimscientist69 Sep 30, 2025
ff2a98a
feat: use prometheus service from automa utilities instead of legacy …
vimscientist69 Sep 30, 2025
bc2a5fc
refactor(infra): moved configs, secrets and dockefiles to their own d…
vimscientist69 Sep 30, 2025
a050d13
fixup! refactor(infra): moved configs, secrets and dockefiles to thei…
vimscientist69 Sep 30, 2025
a41cbe5
fix(NodeMachineDeleter,WebCoreMetric,AutoscalerMetric): call metric o…
vimscientist69 Oct 2, 2025
98d8f97
fix(NodeMachineCreator): added metrics on node machine creation start…
vimscientist69 Oct 2, 2025
924fe61
feat(WebBrowserClient): added metrics to web browser client, todos fo…
vimscientist69 Oct 2, 2025
4de79ad
fix: better error handling and logs
vimscientist69 Oct 3, 2025
4066959
fix(package.json): created working deployment scripts, moved automa c…
vimscientist69 Oct 3, 2025
359d120
fix(Dockerfile): fixed autoscaler image not working on fly.io
vimscientist69 Oct 7, 2025
5354b48
fix(package.json): small fix in deployment scripts
vimscientist69 Oct 7, 2025
f975141
docs: created example env files to know what variables are needed in …
vimscientist69 Oct 7, 2025
5138054
fix: fixed running API image failed
vimscientist69 Oct 7, 2025
9cb4837
fix(APIController): fixed problem where scroll_to_bottom must be prov…
vimscientist69 Oct 7, 2025
4bcb8aa
docs: created example env files for api
vimscientist69 Oct 8, 2025
2084d3e
fix(autoscaler.toml): send metrics to all processes, not just default…
vimscientist69 Oct 8, 2025
bfa080d
fix(SeleniumGridNodeAutoOldMachineDestroyer): small log typo fix
vimscientist69 Oct 8, 2025
2c1736e
fix: move webcore api payload to automa utilities as it is a re-usabl…
vimscientist69 Oct 31, 2025
fdca2ff
fix(Package.resolved,SeleniumGridNodeAutoOldMachineDestroyer): update…
vimscientist69 Oct 31, 2025
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
.swiftlint.yml
.swiftformat
infra/docker-secrets/*
.env
.env.*
!.env.example
!.env.example.*
.fly.toml
3 changes: 3 additions & 0 deletions API/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELENIUM_GRID_HUB_BASE=
FLY_METRICS_TOKEN=

2 changes: 2 additions & 0 deletions API/.env.example.cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ENVIRONMENT=

2 changes: 2 additions & 0 deletions API/.env.example.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SELENIUM_GRID_HUB_BASE=
FLY_METRICS_TOKEN=
3 changes: 0 additions & 3 deletions API/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ DerivedData/
.DS_Store
db.sqlite
.swiftpm
.env
.env.*
!.env.example
default.profraw
26 changes: 15 additions & 11 deletions API/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
# Set up a build area
WORKDIR /build

RUN --mount=type=secret,id=GITHUB_SSH_AUTHENTICATION_TOKEN \
TOKEN=$(cat /run/secrets/GITHUB_SSH_AUTHENTICATION_TOKEN) && \
git config --global url."https://x-access-token:${TOKEN}@github.com/".insteadOf "https://github.com/"

# First just resolve dependencies.
# This creates a cached layer that can be reused
# as long as your Package.swift/Package.resolved
# files do not change.
COPY ./Package.* ./
RUN swift package resolve \
$([ -f ./Package.resolved ] && echo "--force-resolved-versions" || true)
$([ -f ./Package.resolved ] && echo "--force-resolved-versions" || true)

# Copy entire repo into container
COPY . .
Expand All @@ -29,9 +33,9 @@ RUN mkdir /staging
# N.B.: The static version of jemalloc is incompatible with the static Swift runtime.
RUN --mount=type=cache,target=/build/.build \
swift build -c release \
--product API \
--static-swift-stdlib \
-Xlinker -ljemalloc && \
--product API \
--static-swift-stdlib \
-Xlinker -ljemalloc && \
# Copy main executable to staging area
cp "$(swift build -c release --show-bin-path)/API" /staging && \
# Copy resources bundled by SPM to staging area
Expand Down Expand Up @@ -59,13 +63,13 @@ RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
&& apt-get -q update \
&& apt-get -q dist-upgrade -y \
&& apt-get -q install -y \
libjemalloc2 \
ca-certificates \
tzdata \
# If your app or its dependencies import FoundationNetworking, also install `libcurl4`.
# libcurl4 \
# If your app or its dependencies import FoundationXML, also install `libxml2`.
# libxml2 \
libjemalloc2 \
ca-certificates \
tzdata \
# If your app or its dependencies import FoundationNetworking, also install `libcurl4`.
libcurl4 \
# If your app or its dependencies import FoundationXML, also install `libxml2`.
# libxml2 \
&& rm -r /var/lib/apt/lists/*

# Create a vapor user and group with /app as its home directory
Expand Down
78 changes: 48 additions & 30 deletions API/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions API/Sources/API/Controllers/APIController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// APIController.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

import AutomaUtilities
import Vapor

internal struct APIController: RouteCollection {
public func boot(routes: any RoutesBuilder) throws {
let twitterRoute = routes.grouped("api")
twitterRoute.get(use: get)
twitterRoute.post(use: post)
twitterRoute.put(use: put)
twitterRoute.patch(use: patch)
twitterRoute.delete(use: delete)
}

@Sendable
public func get(req: Request) async throws -> String {
let payload = try req.content.decode(AutomaWebCoreAPIEndpointPayload.self)
return try await WebBrowserClient(logger: req.logger, payload: payload).getHTML()
}

// Endpoints where implementation becomes required when making any type of request (GET, POST, etc)
// with a body and headers becomes necessary for the next version of the app
@Sendable
public func post(req _: Request) async throws -> String {
"hello world"
}

@Sendable
public func put(req _: Request) async throws -> String {
"hello world"
}

@Sendable
public func patch(req _: Request) async throws -> String {
"hello world"
}

@Sendable
public func delete(req _: Request) async throws -> String {
"hello world"
}
}
8 changes: 8 additions & 0 deletions API/Sources/API/DataTypes/APIError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// APIError.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

internal enum APIError: Error {
case webBrowserClientError(error: String)
}
25 changes: 25 additions & 0 deletions API/Sources/API/DataTypes/WebCoreMetric.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// WebCoreMetric.swift
// Copyright (c) 2025 GetAutomaApp
// All source code and related assets are the property of GetAutomaApp.
// All rights reserved.

import AutomaUtilities
import Foundation
import Prometheus

internal enum APIMetric {
public static func getWebsiteHTMLCall(
websiteUrl: URL,
jsRender: Bool,
status: MetricStatus
) -> Prometheus.Counter {
MetricsService.global.makeCounter(
name: "get_website_html_call",
labels: [
"status": status.rawValue,
"website_url": websiteUrl.absoluteString,
"js_render": "\(jsRender)",
]
)
}
}
Loading
Loading