Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade build #299

Merged
merged 1 commit into from
Aug 27, 2024
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
20 changes: 12 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
name: ci

on:
pull_request:
branches: [ main ]

workflow_dispatch:

jobs:
ci:
strategy:
matrix:
command: [
"build",
"lint/go",
"test/go",
]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: CI
run: |
cd ./build
go build -o ../bin/.cache/build ./cmd
../bin/.cache/build dev/lint dev/test build
- name: Run ${{ matrix.command }}
run: bin/builder tidy/go ${{ matrix.command }} git/isclean
5 changes: 1 addition & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ jobs:
result-encoding: string
script: return context.ref.replace(/refs\/tags\//, '');
- name: Build OSMan
run: |
cd ./build
go build -o ../bin/.cache/build ./cmd
../bin/.cache/build build
run: bin/builder build
- name: Build RPM
id: rpm
uses: outofforest/rpmbuild@main
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/bin
coverage
22 changes: 22 additions & 0 deletions bin/builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e

# go to root dir of repository
cd "$(dirname "${BASH_SOURCE[0]}")/.." > /dev/null

VERSION=$(git rev-parse --short HEAD)
REPO=$(pwd)
BUILDER="$REPO/bin/.cache/builder-$VERSION"

if [ ! -f "$BUILDER" ]; then
rm -f ./bin/.cache/builder-*

pushd build > /dev/null
go build -trimpath -o "$BUILDER" ./cmd/builder
popd > /dev/null

"$BUILDER" build/me
fi

"$BUILDER" "$@"
9 changes: 6 additions & 3 deletions boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ func copyKernel(buildMountPoint string, storage config.Storage, buildID types.Bu
if err := os.MkdirAll(kernelDir, 0o755); err != nil {
return errors.WithStack(err)
}
if err := copyFile(filepath.Join(kernelDir, "vmlinuz"), filepath.Join(buildBootDir, "vmlinuz"), 0o755); err != nil {
if err := copyFile(filepath.Join(kernelDir, "vmlinuz"), filepath.Join(buildBootDir, "vmlinuz"),
0o755); err != nil {
return errors.WithStack(err)
}
return errors.WithStack(copyFile(filepath.Join(kernelDir, "initramfs.img"), filepath.Join(buildBootDir, "initramfs.img"), 0o600))
return errors.WithStack(copyFile(filepath.Join(kernelDir, "initramfs.img"),
filepath.Join(buildBootDir, "initramfs.img"), 0o600))
})
}

Expand Down Expand Up @@ -83,7 +85,8 @@ func generateGRUB(ctx context.Context, storage config.Storage, s storage.Driver)
if err := os.WriteFile(filepath.Join(grubDir, "grub.cfg"), grubConfig, 0o644); err != nil {
return errors.WithStack(err)
}
return errors.WithStack(os.WriteFile(filepath.Join(grubDir, fmt.Sprintf("grub-%s.cfg", time.Now().UTC().Format(time.RFC3339))), grubConfig, 0o644))
return errors.WithStack(os.WriteFile(filepath.Join(grubDir, fmt.Sprintf("grub-%s.cfg",
time.Now().UTC().Format(time.RFC3339))), grubConfig, 0o644))
})
}

Expand Down
107 changes: 0 additions & 107 deletions build/.golangci.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions build/build.go

This file was deleted.

20 changes: 20 additions & 0 deletions build/cmd/builder/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
me "build"

"github.com/outofforest/build/v2"
"github.com/outofforest/build/v2/pkg/tools/git"
"github.com/outofforest/tools"
"github.com/outofforest/tools/pkg/tools/golang"
)

func main() {
build.RegisterCommands(
build.Commands,
git.Commands,
golang.Commands,
me.Commands,
)
tools.Main()
}
11 changes: 0 additions & 11 deletions build/cmd/main.go

This file was deleted.

16 changes: 10 additions & 6 deletions build/go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
module build

go 1.18
go 1.22

toolchain go1.22.6

require (
github.com/outofforest/build v1.13.1
github.com/outofforest/buildgo v0.8.1
github.com/outofforest/libexec v0.3.9
github.com/outofforest/build/v2 v2.2.0
github.com/outofforest/tools v1.0.0
)

require (
github.com/outofforest/ioc/v2 v2.5.2 // indirect
github.com/outofforest/logger v0.4.0 // indirect
github.com/outofforest/libexec v0.3.9 // indirect
github.com/outofforest/logger v0.5.4 // indirect
github.com/outofforest/parallel v0.2.3 // indirect
github.com/outofforest/run v0.6.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/ridge/must v0.6.0 // indirect
github.com/samber/lo v1.47.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/text v0.17.0 // indirect
)
27 changes: 16 additions & 11 deletions build/go.sum
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/outofforest/build v1.13.1 h1:vF19+5ZkE5oYQbAJvWib+E9/uMU0Mcm2NV7s08gMuIE=
github.com/outofforest/build v1.13.1/go.mod h1:MIsSjcfm0i2+UG9oD7Qp+gEqhT9xB/wTZXQTIfPdATM=
github.com/outofforest/buildgo v0.8.1 h1:qF0PmXAQ1mh9COn53T9WdU4kOh5Xq+uju04cF5r9FFo=
github.com/outofforest/buildgo v0.8.1/go.mod h1:5DePgPaS3N+zh3v+4Cgrx2hMXVLPncMbgTZPmWTP+YE=
github.com/outofforest/build/v2 v2.2.0 h1:0fhPs9BWE4muKYfNZER9yAvEjqanXhrnYw7F0+aUdmM=
github.com/outofforest/build/v2 v2.2.0/go.mod h1:GTO5VGlBK/68raLk81Wdj7JISq/Rsmm02lcZcYKiBgU=
github.com/outofforest/ioc/v2 v2.5.2 h1:4mNzLuzoZTXL/cO0qf1TrSYvejMgbZz5OUhdLzAUbek=
github.com/outofforest/ioc/v2 v2.5.2/go.mod h1:yI+FHuHchC/t6nVo3WJ96qEgCXdHQKFI/4wW2/75YcU=
github.com/outofforest/libexec v0.3.9 h1:KvVLuKDHqpydwNoKm+j36hi9DVPU61X4oHonlZ5cw88=
github.com/outofforest/libexec v0.3.9/go.mod h1:J2rUB/m0ER8UNOHd3/UQM55bvh1cbMwhb8gibeF/zyo=
github.com/outofforest/logger v0.3.3/go.mod h1:+M5sO17Va9V33t28Qs9VqRQ8bFV501Uhq2PtQY+R3Ms=
github.com/outofforest/logger v0.3.4/go.mod h1:wOsyVEu2nnueGK+IZuD1tOWYx6tXGV48earpJsDPT3Y=
github.com/outofforest/logger v0.4.0 h1:Vkcy+ReNlBOHvKMErDTfhHFyb03VRCKIVlo4SctUjVU=
github.com/outofforest/logger v0.4.0/go.mod h1:wOsyVEu2nnueGK+IZuD1tOWYx6tXGV48earpJsDPT3Y=
github.com/outofforest/logger v0.5.4 h1:mRxOxRrm1ppUueQiv+ektljGAGhUM9wOLmkmVpQuMqo=
github.com/outofforest/logger v0.5.4/go.mod h1:czsrxU2w6KlZ31gbJt164H2k0ckoygXbYqCx7V2DAHM=
github.com/outofforest/parallel v0.2.3 h1:DRIgHr7XTL4LLgsTqrj041kulv4ajtbCkRbkOG5psWY=
github.com/outofforest/parallel v0.2.3/go.mod h1:cu210xIjJtOMXR2ERzEcNA2kr0Z0xfZjSKw2jTxAQ2E=
github.com/outofforest/run v0.6.0 h1:t/3vAodvU5L5vJ3BB0qRgfviX+T3JJmLgPN6G2WQs3U=
github.com/outofforest/run v0.6.0/go.mod h1:l7TAtA/zG+7JEH017Qrfm7gzmMyM0gjd+CereJdJSpI=
github.com/outofforest/tools v1.0.0 h1:VS5FJ8ug+TPe+vArMAeWza+Qve+5ENZQxXs6kNSfWIs=
github.com/outofforest/tools v1.0.0/go.mod h1:fn8F7Z4F4SdyWCSIQIf2NvHbN08fDCum+aDVEbxSPUs=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/ridge/must v0.6.0 h1:INravc0/PCJjZgfNADzGOS8/ubNykJYmyJshuz6uiCg=
github.com/ridge/must v0.6.0/go.mod h1:dm1IMngycGzvmpsFY1A5TU18Y5Yg6MgtkJ0iJbca0VA=
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand All @@ -38,20 +39,22 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.22.0/go.mod h1:H4siCOZOrAolnUPJEkfaSjDqyP+BDS0DdDWzwcgt3+U=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c=
go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
Expand All @@ -70,6 +73,8 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand Down
13 changes: 3 additions & 10 deletions build/index.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package build

import (
"github.com/outofforest/build"
"github.com/outofforest/buildgo"
"github.com/outofforest/build/v2/pkg/types"
)

// Commands is a definition of commands available in build system
var Commands = map[string]build.Command{
"setup": {Fn: setup, Description: "Installs tools required by development environment"},
// Commands is a definition of commands available in build system.
var Commands = map[string]types.Command{
"build": {Fn: buildApp, Description: "Builds osman binary"},
"run": {Fn: runApp, Description: "Builds and runs osman binary"},
}

func init() {
buildgo.AddCommands(Commands)
}
Loading