Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .ci/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ stages:

flexapp_build_linux:
stage: build
image: docker:27.4.1-dind
image: docker:latest
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375/
services:
- name: docker:27.4.1-dind
- name: docker:28.5.1-dind
alias: docker
rules:
- if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v/'
Expand All @@ -30,12 +30,12 @@ flexapp_build_linux:

flexapp_build_windows:
stage: build
image: docker:27.4.1-dind
image: docker:latest
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375/
services:
- name: docker:27.4.1-dind
- name: docker:28.5.1-dind
alias: docker
rules:
- if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v/'
Expand Down
2 changes: 1 addition & 1 deletion .ci/dagger.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Ci",
"engineVersion": "v0.15.3",
"engineVersion": "v0.19.0",
"sdk": "python",
"source": "dagger"
}
2 changes: 1 addition & 1 deletion .ci/dagger/src/ci/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@object_type
class Ci:
zig_version = "0.15.1"
zig_version = "0.15.2"
zig_binary = f"zig-x86_64-linux-{zig_version}"

@function
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 ubuntu:24.04
FROM ubuntu:24.04
RUN apt update
RUN apt install curl unzip zsh git sudo \
build-essential wget libssl-dev software-properties-common \
Expand All @@ -10,8 +10,8 @@ RUN curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh

RUN curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /usr/bin

ARG ZIG_VERSION_BINARY=zig-x86_64-linux-0.15.1
ARG ZIG_VERSION=0.15.1
ARG ZIG_VERSION_BINARY=zig-x86_64-linux-0.15.2
ARG ZIG_VERSION=0.15.2
ARG ZLS_VERSION=0.15.0
# ARG ZIG_DOWNLOAD=https://ziglang.org/builds/$ZIG_VERSION.tar.xz
ARG ZIG_DOWNLOAD=https://ziglang.org/download/$ZIG_VERSION/$ZIG_VERSION_BINARY.tar.xz
Expand Down
2 changes: 1 addition & 1 deletion .flox/env/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ zsh.pkg-path = "zsh"
starship.pkg-path = "starship"
docker.pkg-path = "docker"
zig.pkg-path = "zig"
zig.version = "0.15.1"
zig.version = "0.15.2"
zls.pkg-path = "zls"
zls.version = "0.15.0"
# hello.pkg-path = "hello"
Expand Down
6 changes: 3 additions & 3 deletions .forgejo/workflows/flexapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

jobs:
testing:
runs-on: codeberg-tiny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Dagger Rust Tests
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
once:
needs: testing
name: Create Forgejo release
runs-on: codeberg-tiny
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
strategy:
matrix:
os: [linux, windows]
platform: [codeberg-tiny]
platform: [ubuntu-latest]

runs-on: ${{ matrix.platform }}

Expand Down
35 changes: 24 additions & 11 deletions .gitea/workflows/flexapp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: smdc_portal
name: flexapp

on:
push:
Expand All @@ -18,20 +18,33 @@ on:

jobs:
testing:
strategy:
matrix:
optimize: [ReleaseSafe, ReleaseFast]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
with:
version: master
cache-key: ${{ matrix.optimize }}
- run: zig test src/root.zig -O${{ matrix.optimize }}
- name: Dagger Rust Tests
run: |
apt update && apt install -y curl unzip wget docker.io

# Try to connect to Docker
if docker info; then
echo "Docker is working!"
else
echo "Docker daemon not accessible, checking alternatives..."

# Check if we can start dockerd
echo "Attempting to start Docker daemon..."
dockerd --host=unix:///var/run/docker.sock &
sleep 10
docker info || echo "Still no Docker access"
fi

curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh;
export PATH="$HOME/.local/bin:$PATH";
cd .ci;
dagger call tests --src=../;

once:
name: Create GitHub release
name: Create Gitea release
runs-on: 'ubuntu-latest'
needs: testing
outputs:
Expand All @@ -46,7 +59,7 @@ jobs:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Automated Release by GitHub Action CI
Automated Release by Gitea Action CI
draft: false
prerelease: false

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/flexapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:
tags:
- "release-v[0-9]+.[0-9]+.[0-9]+"
- "release-v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
pull_request:
branches:
- main
paths:
- RELEASE_NOTES.md
# pull_request:
# branches:
# - main
# paths:
# - RELEASE_NOTES.md

jobs:
testing:
Expand All @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
with:
version: master
version: 0.15.2
cache-key: ${{ matrix.optimize }}
- run: zig test src/root.zig -O${{ matrix.optimize }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
- uses: actions/checkout@v4
- uses: mlugg/setup-zig@v2
with:
version: master
version: 0.15.2
cache-key: ${{ matrix.optimize }}
- run: zig test src/root.zig -O${{ matrix.optimize }}
12 changes: 6 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ stages:

flexapp_testing:
stage: .pre
image: docker:27.4.1-dind
image: docker:latest
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375/
services:
- name: docker:27.4.1-dind
- name: docker:28.5.1-dind
alias: docker
rules:
- if: $CI_COMMIT_TAG =~ /^release-.*/
Expand All @@ -28,12 +28,12 @@ flexapp_testing:

flexapp_build_linux:
stage: build
image: docker:27.4.1-dind
image: docker:latest
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375/
services:
- name: docker:27.4.1-dind
- name: docker:28.5.1-dind
alias: docker
rules:
- if: $CI_COMMIT_TAG =~ /^release-.*/
Expand All @@ -55,12 +55,12 @@ flexapp_build_linux:

flexapp_build_windows:
stage: build
image: docker:27.4.1-dind
image: docker:28.5.1-dind
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_HOST: tcp://docker:2375/
services:
- name: docker:27.4.1-dind
- name: docker:28.5.1-dind
alias: docker
rules:
- if: $CI_COMMIT_TAG =~ /^release-.*/
Expand Down
101 changes: 101 additions & 0 deletions src/download.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
const std = @import("std");
const helper = @import("helper.zig");
pub fn download(allocator: std.mem.Allocator, url: []const u8) ![]const u8 {
std.debug.print("{s} {s}\n", .{ "Starting download for", url });

var client = std.http.Client{
.allocator = allocator,
};
defer client.deinit();

try client.ca_bundle.rescan(allocator);
// defer client.ca_bundle.deinit(allocator);
// std.debug.print("CA bundle size: {}\n", .{client.ca_bundle.bytes.items.len});

const uri = try std.Uri.parse(url);
var buf: [8192]u8 = undefined;
var req = client.request(.GET, uri, .{
.redirect_behavior = .unhandled,
.keep_alive = false,
}) catch |err| {
std.debug.print("Error creating request: {}\n", .{err});
return "unknown.txt";
};
defer req.deinit();

req.redirect_behavior = .unhandled;
try req.sendBodiless();
var response = try req.receiveHead(&buf);

if (response.head.status != .ok) {
if (response.head.status != .found) {
std.debug.print("Response Failed: {any}\n", .{response.head.status});
return "unknown.txt";
}
}

var filename: []const u8 = "unknown.txt";
var iter = response.head.iterateHeaders();
while (iter.next()) |header| {
std.debug.print("Name:{s}, Value:{s}\n", .{ header.name, header.value });
if (std.mem.containsAtLeast(u8, header.value, 1, "attachment; filename=")) {
var filename1 = std.mem.splitSequence(u8, header.value, "filename=");
// Consume first iterator
_ = filename1.first();
filename = filename1.rest();
// Check for more stuff in filename
var filename2 = std.mem.splitSequence(u8, filename, ";");
filename = filename2.first();
break;
}
}

if (std.mem.eql(u8, filename, "unknown.txt")) {
var filename1 = std.mem.splitSequence(u8, url, "/");
while (filename1.next()) |f| {
filename = f;
}

filename = try helper.replaceAll(allocator, filename, "?*<|", "_____");
}
const filename_final = try allocator.dupe(u8, filename);

const file = try std.fs.cwd().createFile(
filename,
.{ .read = true },
);
allocator.free(filename);
defer file.close();

var buffer: [64]u8 = undefined;
const decompress_buffer: []u8 = switch (response.head.content_encoding) {
.identity => &.{},
.zstd => try allocator.alloc(u8, std.compress.zstd.default_window_len),
.deflate, .gzip => try allocator.alloc(u8, std.compress.flate.max_window_len),
.compress => return error.UnsupportedCompressionMethod,
};
defer allocator.free(decompress_buffer);

var transfer_buffer: [64]u8 = undefined;
var decompress: std.http.Decompress = undefined;
const reader = response.readerDecompressing(&transfer_buffer, &decompress, decompress_buffer);

var file_writer: std.fs.File.Writer = .init(file, &buffer);
_ = reader.streamRemaining(&file_writer.interface) catch |err| {
std.debug.print("Error during download/decompression: {}\n", .{err});
return "unknown.txt";
};
// Flush remaining buffer just in case.
try file_writer.interface.flush();

return filename_final;
}

test "download function" {
const testing_allocator = std.testing.allocator;

const url = "https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise64.msi";
const filename = try download(testing_allocator, url);
defer testing_allocator.free(filename);
std.debug.print("Downloaded file: {s}\n", .{filename});
}
14 changes: 14 additions & 0 deletions src/helper.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ pub fn replace(allocator: std.mem.Allocator, haystack: []const u8, needle: []con
}
return result.toOwnedSlice(allocator);
}
pub fn replaceAll(allocator: std.mem.Allocator, haystack: []const u8, needle: []const u8, replacement: []const u8) ![]u8 {
var result: std.ArrayList(u8) = .empty;
defer result.deinit(allocator);
outer: for (haystack) |c| {
for (needle, 0..) |ctr, i| {
if (c == ctr) {
try result.append(allocator, replacement[i]);
continue :outer;
}
}
try result.append(allocator, c);
}
return result.toOwnedSlice(allocator);
}

pub fn test_file_path(path: []const u8) !bool {
const file = std.fs.cwd().openFile(path, .{}) catch |err| {
Expand Down
Loading