Commit graph

20 commits

Author SHA1 Message Date
c7c286204e
temporarilly disable tests in ci 2026-01-31 14:47:55 -06:00
92c7675141
Update CI to Rust 1.91 to match local environment 2026-01-31 14:42:51 -06:00
c0fe57cd44
fix: properly inject version into Docker image builds
The agent version was always showing 0.1.0 because build.rs tried to
run 'git describe' inside the Docker build, but .git directory wasn't
copied into the image.

Changes:
- Add VERSION build arg to Dockerfile
- Pass VERSION as env var to cargo build commands
- Update GitLab CI to pass --build-arg VERSION
- Modify build.rs to prefer BUILD_VERSION env var over git commands

This ensures the version displayed by the agent matches the Docker
image tag it was built with.
2026-01-19 15:31:26 -06:00
0b3cc9121e
Add comprehensive unit test coverage (29.19%)
Add 73 unit tests covering all testable business logic:

- src/snmp/types.rs: 100% coverage (17/17 lines)
  * SnmpError display formatting
  * SnmpValue conversions (as_i64, as_f64)

- src/snmp/client.rs: 34.4% coverage (32/93 lines)
  * OID parsing/formatting/validation
  * SNMP value conversion for all types
  * Error mapping from snmp crate
  * Helper functions (starts_with, format_oid)

- src/ping.rs: 65.2% coverage (58/89 lines)
  * ICMP checksum calculation and verification
  * Echo request packet building
  * Reply packet parsing (raw and IP-wrapped)
  * IP header length extraction (IHL field)
  * Error handling for invalid packets

- src/version.rs: 54.0% coverage (27/50 lines)
  * Version parsing with optional 'v' prefix
  * Version comparison and sorting
  * Docker Hub response deserialization
  * Latest version extraction from tags

- src/websocket_client.rs: 7.7% coverage (17/221 lines)
  * SnmpValue to string conversion
  * Agent ID generation
  * Phoenix message serialization/deserialization
  * Helper functions (get_uptime_seconds, get_local_ip)

- src/main.rs: 20.0% coverage (11/55 lines)
  * SimpleLogger enabled() logic
  * HTTP/HTTPS to WebSocket URL conversion

- .gitlab-ci.yml: Add 'cargo test' to CI pipeline

Uncovered code requires integration testing:
- Network I/O (WebSocket, HTTP, Docker Hub API)
- System privileges (raw ICMP sockets)
- External services (SNMP devices, WebSocket servers)
- Runtime initialization (tokio main, logger setup)

All 73 tests pass. No test failures.
2026-01-19 15:07:00 -06:00
efa8404ea6
rewrite with much simpler runtime 2026-01-16 17:27:10 -06:00
097c4bd581
Add automatic semver versioning for agent
Features:
- Parse and compare semantic versions from Docker Hub
- Check if current version is outdated on startup
- Only pull updates when newer version is available
- GitLab CI now tags images with Cargo.toml version
- Created bump-version.sh script for easy version bumping

How it works:
1. Cargo.toml contains source of truth version (0.1.0)
2. GitLab CI extracts version and tags Docker images with it
3. Agent queries Docker Hub for all semver tags
4. Compares current version against latest available
5. Only pulls and restarts if newer version exists

Version bumping workflow:
  ./scripts/bump-version.sh patch  # 0.1.0 -> 0.1.1
  ./scripts/bump-version.sh minor  # 0.1.0 -> 0.2.0
  ./scripts/bump-version.sh major  # 0.1.0 -> 1.0.0

This creates git commit and tag, ready to push.
2026-01-15 12:52:36 -06:00
c448b3dcfa
Optimize CI build performance - build amd64 only for main branch
The multi-architecture builds (amd64 + arm64) were taking 15-20+ minutes
due to QEMU emulation for ARM64 cross-compilation. This is too slow for
regular development iteration.

Changes:
- Main branch builds: amd64 only (much faster, ~3-5 minutes)
- Tagged releases: Still build multi-arch (amd64 + arm64)
- Added Docker layer caching to speed up subsequent builds
- Cache stored in registry for persistence across CI runs

The 'latest' tag will be amd64-only from main branch. Users needing
ARM64 should use a specific version tag (e.g., v0.1.0).
2026-01-14 10:03:57 -06:00
813dafb46b
Fix GitLab CI buildx configuration for multi-arch builds
Fixed docker buildx errors in CI/CD pipeline:

1. Set DOCKER_TLS_CERTDIR to empty string to disable TLS
   (buildx with docker-in-docker doesn't work well with TLS certs)

2. Added fallback to reuse existing builder if creation fails
   (docker buildx create ... || docker buildx use ...)

This fixes the error:
'could not create a builder instance with TLS data loaded from environment'
2026-01-14 09:44:32 -06:00
10a3c4353f
Fix buildx setup for GitLab DinD environment 2026-01-13 15:44:19 -06:00
2b1d779279
Add multi-architecture build support (amd64, arm64) 2026-01-13 14:07:21 -06:00
3db5e975a5
Remove nonexistent .cargo/ from CI cache config 2026-01-13 14:00:06 -06:00
82f97deeb2
Add protobuf compiler to CI and Docker build 2026-01-13 13:55:12 -06:00
03dab21a0a
Switch to Docker Hub and use shared runners
- Change registry from GitLab to Docker Hub (gmcintire/towerops-agent)
- Update authentication to use DOCKERHUB_USERNAME and DOCKERHUB_TOKEN
- Remove vntx runner tags to use GitLab shared runners
2026-01-13 13:45:32 -06:00
1f9bdd57cf
rebuild docker image 2026-01-13 13:43:59 -06:00
953d044c9b
change build dest 2026-01-09 17:02:03 -06:00
979369b502
continuing build 2026-01-09 13:57:27 -06:00
fd1b02a6ea
update ci rust version 2026-01-09 13:36:10 -06:00
125b0f427e
update ci rust version 2026-01-09 13:34:43 -06:00
b0fb9c2a78
build multiarch docker container 2026-01-09 13:33:35 -06:00
5263175182
build docker image in ci 2026-01-09 13:32:11 -06:00