Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
803389a
Fix docgen CI error, update docgen.sh, remove old CLI docs, add docge…
Jul 24, 2025
e558f02
Increase state tracking overhead threshold for performance test
Jul 24, 2025
4bf84fc
Update workflow to start MongoDB and document requirement in README
Jul 24, 2025
f60a626
Fix CI errors, update enums, documentation links, and dependencies fo…
Jul 25, 2025
6dce89c
Fix ErrorLog marshaling and restore TimeDuration enum for CI compatib…
Jul 25, 2025
cbd9b1b
Revert timeDurationEnum to standard values for validation compatibility
Jul 25, 2025
9f83b3a
docs(api): update API docs, error log models, and CLI docs for ErrorL…
Jul 25, 2025
bcb7951
Fix data race in analytics global state and update time_duration enum…
Jul 25, 2025
0341d85
Fix swagger model conflict markers
Jul 25, 2025
dba5022
Update dependencies: pkg/sftp and others for permission string fix
Jul 25, 2025
2416fd5
fix: protect docs/en/cli-reference from deletion in docgen.sh
Jul 25, 2025
d927346
Fix gofmt formatting issues
Jul 25, 2025
1c7bb5c
Sync go.mod/go.sum and generated files
Jul 25, 2025
dc3fb80
refactor: migrate from http to standard httptransport client
Jul 25, 2025
2636ec7
feat: add cache management and cleanup
Jul 25, 2025
fda5df9
fix: update dependencies and format code
Jul 25, 2025
cd7e50c
ci: ensure swagger client directory exists before code generation
Jul 25, 2025
11b4f64
ci: improve swagger directory handling and add debug info
Jul 25, 2025
574ea0d
refactor: update TimeDuration type in swagger to use int64 nanosecond…
Jul 25, 2025
e17fa99
chore: regenerate swagger client code for TimeDuration changes
Jul 25, 2025
fa266ca
fix: update code to use int64 nanoseconds for time durations
Jul 25, 2025
c5da522
test: update tests to use int64 nanoseconds for time durations
Jul 25, 2025
225db76
chore: fix swagger generation path
Jul 25, 2025
169afc5
ci: add MySQL service to GitHub Actions workflow
Jul 25, 2025
e6946ce
ci: enhance MySQL permissions and add verification steps
Jul 25, 2025
3559c81
ci: add PostgreSQL service and verification
Jul 25, 2025
147b681
fix: improve CI workflow reliability
Jul 25, 2025
98f6431
fix: resolve database CI issues
Jul 25, 2025
bdc2092
fix: create postgresql root role and grant necessary permissions for …
Jul 25, 2025
f637be8
ci: improve PostgreSQL test database setup with template and automati…
Jul 25, 2025
e4e4654
ci: fix Postgres setup and benchmarks, remove event triggers, pin swa…
Jul 25, 2025
e74851d
ci: refine Go test workflow and ensure consistent all jobs execution
Jul 25, 2025
514846a
ci: rename go-check job to 'All' to ensure pending checks run correctly
Jul 25, 2025
b754bca
ci: enhance GitHub Actions workflow configurations
Jul 25, 2025
dd8622e
docs: fix documentation generation and regenerate CLI docs
Jul 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .github/actions/go-check-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ runs:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
key: ${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}-${{ github.ref }}-
${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}-
${{ matrix.os }}-golang-${{ matrix.go }}-

- name: Setup Go
Expand Down
9 changes: 8 additions & 1 deletion .github/actions/go-test-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ description: Setup Cache
runs:
using: "composite"
steps:
- name: Clean Go cache directories
shell: bash
run: |
rm -rf ~/.cache/go-build
rm -rf ~/go/pkg/mod
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cache doesn't start empty with a fresh container?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why isn't this needed on the go-check-setup action?

- name: Setup Golang caches
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
key: ${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}-${{ github.ref }}-
${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}-
${{ matrix.os }}-golang-${{ matrix.go }}-
- name: Setup PostgreSQL database
uses: ikalnytskyi/action-setup-postgres@v6
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/cache-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Cache Cleanup
on:
workflow_dispatch: # Manual trigger
schedule:
- cron: '0 0 * * 0' # Run weekly on Sunday at midnight

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup
run: |
# Get all cache keys
CACHE_KEYS=$(gh cache list -L 1000 | awk '{print $1}')

# Calculate total size
TOTAL_SIZE=$(gh cache list -L 1000 | awk '{sum += $2} END {print sum}')

# If total size > 8GB (keeping buffer from 10GB limit)
if [ "$TOTAL_SIZE" -gt 8000000000 ]; then
# Delete older caches until we're under 8GB
echo "$CACHE_KEYS" | while read key; do
gh cache delete "$key" -f
TOTAL_SIZE=$(gh cache list -L 1000 | awk '{sum += $2} END {print sum}')
if [ "$TOTAL_SIZE" -lt 8000000000 ]; then
break
fi
done
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Documentation Generation

on:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
docgen:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Initialize database for doc generation
run: |
cd singularity
./singularity admin init
- name: Generate documentation
run: |
cd singularity
sh docgen.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This docs are generated, but not stored anywhere. I don't think this is needed

82 changes: 76 additions & 6 deletions .github/workflows/go-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: Go Checks

on:
pull_request:
branches: [main, develop]
push:
branches: ["main"]
branches: [main, develop]
workflow_dispatch:

permissions:
Expand All @@ -14,19 +15,88 @@ concurrency:
cancel-in-progress: true

jobs:
go-check:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
go-check-all:
name: go-check / All
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: singularity
MYSQL_USER: singularity
MYSQL_PASSWORD: singularity
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3

postgres:
image: postgres:15
env:
POSTGRES_USER: singularity
POSTGRES_PASSWORD: singularity
POSTGRES_DB: singularity
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21.x"

- name: Wait for PostgreSQL
run: |
echo "Waiting for PostgreSQL..."
for i in {1..10}; do
if PGPASSWORD=singularity psql -h localhost -U singularity -d singularity -c "SELECT 1" > /dev/null 2>&1; then
echo "Postgres is ready!"
break
fi
sleep 3
done

- name: Verify MySQL connection
run: mysql -h127.0.0.1 -P3306 -usingularity -psingularity -e "SELECT VERSION();"

- name: Verify PostgreSQL connection
run: PGPASSWORD=singularity psql -h localhost -U singularity -d singularity -c "SELECT version();"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you create a MySQL connection and a PSQL connection? Singularity seems to support both, so I could understand wanting to test with both, but I don't see you passing a connection string to Singularity anywhere so I think this test is still using sqllite. Have I missed where you configure the database you set up for testing?

https://data-programs.gitbook.io/singularity/installation/deploy-to-production


- name: Ensure swagger directories exist
run: mkdir -p client/swagger/client

- name: Install swagger tools
run: go install github.com/go-swagger/go-swagger/cmd/[email protected]

- name: Generate code
run: go generate ./client/swagger/...

- name: Build
run: go build ./...

- name: Run tests
run: go test -v ./...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you running go test inside go check?


staticcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
go-version: "1.21.x"

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest
Expand Down
52 changes: 49 additions & 3 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ name: Go Test

on:
pull_request:
branches: [main, develop]
push:
branches: ["main"]
branches: [main, develop]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

workflow_dispatch:

permissions:
Expand All @@ -14,5 +15,50 @@ concurrency:
cancel-in-progress: true

jobs:
go-test:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
go-test-this:
name: go-test / ${{ matrix.os }} (go this)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3

- name: Start MongoDB
if: runner.os == 'Linux'
uses: supercharge/[email protected]
with:
mongodb-version: '6.0'
mongodb-port: 27018

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Run Go Tests
run: go test ./...

go-test-next:
name: go-test / ${{ matrix.os }} (go next)
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v3

- name: Start MongoDB
if: runner.os == 'Linux'
uses: supercharge/[email protected]
with:
mongodb-version: '6.0'
mongodb-port: 27018

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Run Go Tests
run: go test ./...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow for testing is substantially different from the IPDX workflow: https://github.com/ipdxco/unified-github-workflows/blob/main/.github/workflows/go-test.yml

Without using an AI summary, can you please explain why you made these changes and what the effect on testing will be? The IPDX workflow seems much more robust

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, why is there both a go-test-next job and a go-test-this job? They seem to be exactly the same except for the name?

13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,16 @@ The internal tool used by `js-singularity` to regenerate the CAR that captures t

## License
Dual-licensed under [MIT](https://github.com/filecoin-project/lotus/blob/master/LICENSE-MIT) + [Apache 2.0](https://github.com/filecoin-project/lotus/blob/master/LICENSE-APACHE)

## Integration Tests & MongoDB

Some integration tests require a MongoDB instance running on `localhost:27018`.

- **CI:** MongoDB is automatically started on port 27018 in GitHub Actions workflows.
- **Local Development:** You must start MongoDB locally on port 27018 before running tests:

```bash
mongod --port 27018
```

If MongoDB is not available, related tests will be skipped or fail with a connection error.
28 changes: 27 additions & 1 deletion analytics/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import (

const flushInterval = time.Hour

var Enabled = true
var (
mu sync.RWMutex
Enabled = true
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What problem does switching this to a mutex fix?


var logger = log.Logger("analytics")

Expand All @@ -37,6 +40,8 @@ var logger = log.Logger("analytics")
// Returns:
// - An error if there are issues fetching the instance id from the database or if the database appears empty.
func Init(ctx context.Context, db *gorm.DB) error {
mu.Lock()
defer mu.Unlock()
if Instance != "" {
return nil
}
Expand Down Expand Up @@ -68,6 +73,27 @@ var (
Identity string
)

// GetInstance safely returns the Instance value
func GetInstance() string {
mu.RLock()
defer mu.RUnlock()
return Instance
}

// GetIdentity safely returns the Identity value
func GetIdentity() string {
mu.RLock()
defer mu.RUnlock()
return Identity
}

// IsEnabled safely returns the Enabled value
func IsEnabled() bool {
mu.RLock()
defer mu.RUnlock()
return Enabled
}

type Collector struct {
mu sync.Mutex
packJobEvents []PackJobEvent
Expand Down
Loading
Loading