Skip to content

Commit

Permalink
add: GitHub actions building
Browse files Browse the repository at this point in the history
This commit adds GitHub actions "build.yml" file to pre-build FrequenC.
  • Loading branch information
ThePedroo committed May 3, 2024
1 parent f4c2c68 commit 2c05be4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build FrequenC

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Install Dependencies
run: sudo apt-get install -y libssl-dev clang make

- name: Build
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_BRANCH: ${{ github.ref_name }}
run: CFLAGS="-Ofast -fno-signed-zeros -fno-trapping-math -funroll-loops" make

- name: Archive Build
uses: actions/upload-artifact@v2
with:
name: build-artifact
path: FrequenC
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ ALLOW_UNSECURE_RANDOM = 0
# Development
HARDCODED_SESSION_ID = 0

# Github Actions
GITHUB_SHA ?= "unknown"
GITHUB_BRANCH ?= "unknown"

SRC_DIR = lib external sources
OBJ_DIR = obj

CVERSION = -std=c99
CFLAGS ?= -Ofast -march=native -fno-signed-zeros -fno-trapping-math -funroll-loops
CFLAGS ?= -Ofast -march=native -fno-signed-zeros -fno-trapping-math -funroll-loops
LDFLAGS ?= -Iinclude -Iexternal -Isources -pthread
OPTIONS = -DPORT=$(PORT) -DAUTHORIZATION=\"$(AUTHORIZATION)\" -DALLOW_UNSECURE_RANDOM=$(ALLOW_UNSECURE_RANDOM) $(if $(CSOCKET_SECURE),-lssl -lcrypto -DCSOCKET_SECURE -DCSOCKET_KEY=\"$(CSOCKET_KEY)\" -DCSOCKET_CERT=\"$(CSOCKET_CERT)\",) $(if $(TCPLIMITS_EXPERIMENTAL_SAVE_MEMORY),-DTCPLIMITS_EXPERIMENTAL_SAVE_MEMORY,) -DHARDCODED_SESSION_ID=$(HARDCODED_SESSION_ID)
OPTIONS = -DPORT=$(PORT) -DAUTHORIZATION=\"$(AUTHORIZATION)\" -DALLOW_UNSECURE_RANDOM=$(ALLOW_UNSECURE_RANDOM) $(if $(CSOCKET_SECURE),-lssl -lcrypto -DCSOCKET_SECURE -DCSOCKET_KEY=\"$(CSOCKET_KEY)\" -DCSOCKET_CERT=\"$(CSOCKET_CERT)\",) $(if $(TCPLIMITS_EXPERIMENTAL_SAVE_MEMORY),-DTCPLIMITS_EXPERIMENTAL_SAVE_MEMORY,) -DHARDCODED_SESSION_ID=$(HARDCODED_SESSION_ID) -DGITHUB_SHA=$(GITHUB_SHA) -DGITHUB_BRANCH=$(GITHUB_BRANCH)
CHECK_FLAGS = -Wpedantic -Wall -Wextra -Werror -Wformat -Wuninitialized -Wshadow

SRCS = $(foreach dir,$(SRC_DIR),$(wildcard $(dir)/*.c))
Expand Down
15 changes: 9 additions & 6 deletions lib/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
#define VERSION_MINOR 0
#define VERSION_PATCH 0

#define GIT_BRANCH "main"
#ifndef GIT_BRANCH
#define GIT_BRANCH "unknown"
#endif

#ifndef GIT_COMMIT
#define GIT_COMMIT "unknown"
#define GIT_COMMIT_TIME "-1"
#endif

#define SUPPORTED_SOURCES "[]"
#define SUPPORTED_FILTERS "[]"
Expand Down Expand Up @@ -294,14 +298,13 @@ void callback(struct csocket_server_client *client, int socket_index, struct htt
"\"builtTime\":-1,"
"\"git\":{"
"\"branch\":\"%s\","
"\"commit\":\"%s\","
"\"commitTime\":%s"
"\"commit\":\"%s\""
"},"
"\"sourceManagers\":%s,"
"\"filters\":%s"
"}",
VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, GIT_BRANCH, GIT_COMMIT, GIT_COMMIT_TIME, SUPPORTED_SOURCES, SUPPORTED_FILTERS);
VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, GIT_BRANCH, GIT_COMMIT, SUPPORTED_SOURCES, SUPPORTED_FILTERS);

frequenc_stringify_int(payload_length, payload_length_str, sizeof(payload_length_str));

struct httpserver_response response = {
Expand Down

0 comments on commit 2c05be4

Please sign in to comment.