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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 1 addition & 3 deletions .github/actions/go-check-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ runs:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}-${{ github.ref }}-${{ github.sha }}
key: ${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
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: 1 addition & 8 deletions .github/actions/go-test-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@ 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
- 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') }}-${{ github.ref }}-${{ github.sha }}
key: ${{ matrix.os }}-golang-${{ matrix.go }}-${{ hashFiles('**/go.sum') }}
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: 0 additions & 31 deletions .github/workflows/cache-cleanup.yml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/docgen.yml

This file was deleted.

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

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

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

jobs:
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();"

- 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 ./...
go-check:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]

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

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

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

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

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

jobs:
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 ./...
go-test:
uses: ipdxco/unified-github-workflows/.github/workflows/[email protected]
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,16 +427,3 @@ 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: 1 addition & 27 deletions analytics/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ import (

const flushInterval = time.Hour

var (
mu sync.RWMutex
Enabled = true
)
var Enabled = true

var logger = log.Logger("analytics")

Expand All @@ -40,8 +37,6 @@ 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 @@ -73,27 +68,6 @@ 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