Simplify Go installation and support standard OpenCode releases
This commit is contained in:
@@ -2,8 +2,8 @@ package pipeline
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"pipelines/internal/protocol"
|
||||
"pipelines/internal/stage"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
|
||||
func TestShowcaseDefinitions(t *testing.T) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"os"
|
||||
"pipelines/internal/protocol"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package pipeline
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
|
||||
func (s *Store) initRuns() error {
|
||||
@@ -27,6 +27,9 @@ started_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, finished_at TEXT, PRIMARY KE
|
||||
CREATE INDEX IF NOT EXISTS run_latest ON pipeline_runs(id DESC);
|
||||
CREATE TABLE IF NOT EXISTS step_notifications (
|
||||
run_id INTEGER NOT NULL, sequence INTEGER NOT NULL, receipts_json TEXT NOT NULL,
|
||||
PRIMARY KEY(run_id,sequence), FOREIGN KEY(run_id,sequence) REFERENCES run_steps(run_id,sequence));
|
||||
CREATE TABLE IF NOT EXISTS run_session_owners (
|
||||
run_id INTEGER NOT NULL, sequence INTEGER NOT NULL, backend TEXT NOT NULL, reference TEXT NOT NULL DEFAULT '',
|
||||
PRIMARY KEY(run_id,sequence), FOREIGN KEY(run_id,sequence) REFERENCES run_steps(run_id,sequence));`)
|
||||
return err
|
||||
}
|
||||
@@ -211,8 +214,49 @@ func (s *Store) BeginStep(ctx context.Context, id int64, sequence int, key strin
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
func (s *Store) RunSession(ctx context.Context, id int64, sequence int, session string, active bool) error {
|
||||
return affected(s.db.ExecContext(ctx, "UPDATE run_steps SET session_id=?,agent_active=? WHERE run_id=? AND sequence=? AND status='running'", session, active, id, sequence))
|
||||
func (s *Store) RunSession(ctx context.Context, id int64, sequence int, session string, active bool, metadata ...string) error {
|
||||
tx, err := s.db.BeginTx(ctx, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
if err = affected(tx.ExecContext(ctx, "UPDATE run_steps SET session_id=?,agent_active=? WHERE run_id=? AND sequence=? AND status='running'", session, active, id, sequence)); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(metadata) > 0 {
|
||||
backend := metadata[0]
|
||||
if backend == "" {
|
||||
backend = "v2"
|
||||
}
|
||||
reference := ""
|
||||
if len(metadata) > 1 {
|
||||
reference = metadata[1]
|
||||
}
|
||||
if _, err = tx.ExecContext(ctx, "INSERT INTO run_session_owners(run_id,sequence,backend,reference) VALUES(?,?,?,?) ON CONFLICT(run_id,sequence) DO UPDATE SET backend=excluded.backend,reference=excluded.reference", id, sequence, backend, reference); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
type SessionOwner struct{ ID, Backend, Directory, Reference string }
|
||||
|
||||
func (s *Store) ActiveSessionOwners(ctx context.Context) ([]SessionOwner, error) {
|
||||
rows, err := s.db.QueryContext(ctx, `SELECT s.session_id,COALESCE(o.backend,'v2'),r.workspace,COALESCE(o.reference,'')
|
||||
FROM run_steps s JOIN pipeline_runs r ON r.id=s.run_id LEFT JOIN run_session_owners o ON o.run_id=s.run_id AND o.sequence=s.sequence WHERE s.agent_active=1 AND s.session_id<>''`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var owners []SessionOwner
|
||||
for rows.Next() {
|
||||
var owner SessionOwner
|
||||
if err = rows.Scan(&owner.ID, &owner.Backend, &owner.Directory, &owner.Reference); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
owners = append(owners, owner)
|
||||
}
|
||||
return owners, rows.Err()
|
||||
}
|
||||
|
||||
func (s *Store) FinishStep(ctx context.Context, id int64, step protocol.RunStep) error {
|
||||
|
||||
@@ -2,7 +2,7 @@ package pipeline
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ package pipeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
"pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"pipelines/internal/stage"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
)
|
||||
|
||||
// StageDefinition adapts normalized/persisted graph data for type implementations.
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"pipelines/internal/protocol"
|
||||
"pipelines/internal/stage"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
)
|
||||
|
||||
type constantStage struct{}
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"pipelines/internal/protocol"
|
||||
"pipelines/internal/stage"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -3,9 +3,9 @@ package pipeline
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
"path/filepath"
|
||||
"pipelines/internal/protocol"
|
||||
"pipelines/internal/stage"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
@@ -2,8 +2,8 @@ package pipeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.a-wan.net/alan/pipelines/internal/stage"
|
||||
"path/filepath"
|
||||
"pipelines/internal/stage"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user