Skip to content

Commit c4d83ac

Browse files
committed
chore: refactor to allow for arh development
1 parent 157d1ff commit c4d83ac

33 files changed

+1729
-763
lines changed

.github/workflows/pr_check.yml

+78-9
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,89 @@ jobs:
77
fail-fast: false
88
matrix:
99
include:
10-
# - platform: 'macos-latest' # for Arm based macs (M1 and above).
11-
# args: '--verbose --target aarch64-apple-darwin'
12-
# platform-name: 'Macos-M1'
13-
# - platform: 'macos-latest' # for Intel based macs.
14-
# args: '--verbose --target x86_64-apple-darwin'
15-
# platform-name: 'Macos-Intel'
1610
- platform: 'macos-latest' # for Univrsal based macs.
17-
args: '--verbose --target universal-apple-darwin'
11+
args: '--verbose --target universal-apple-darwin --features aws-sdk'
1812
platform-name: 'Macos-Universal'
1913
- platform: 'ubuntu-latest' # for Tauri v1 you could replace this with ubuntu-20.04.
20-
args: '--verbose'
14+
args: '--verbose --features aws-sdk'
2115
platform-name: 'Linux'
2216
- platform: 'windows-latest'
23-
args: '--verbose'
17+
args: '--verbose --features aws-sdk'
18+
platform-name: 'Windows'
19+
runs-on: ${{ matrix.platform }}
20+
steps:
21+
- name: Set git to use LF
22+
run: |
23+
git config --global core.autocrlf false
24+
git config --global core.eol lf
25+
- uses: actions/checkout@v4
26+
- uses: bluwy/substitute-string-action@v3
27+
id: sub
28+
with:
29+
_input-file: 'src-tauri/src/main.rs'
30+
_output-file: 'src-tauri/src/main.rs'
31+
_format-key: '%%key%%'
32+
PROFILE: 'release'
33+
WOMBAT_API_URL: ${{ secrets.WOMBAT_API_URL }}
34+
WOMBAT_API_USER: ${{ secrets.WOMBAT_API_USER }}
35+
WOMBAT_API_PASSWORD: ${{ secrets.WOMBAT_API_PASSWORD }}
36+
- name: Install pnpm
37+
uses: pnpm/action-setup@v4
38+
with:
39+
version: 9
40+
- name: setup node
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: 22
44+
cache: 'pnpm'
45+
- name: install Rust
46+
uses: dtolnay/rust-toolchain@stable
47+
with:
48+
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
49+
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
50+
- name: install dependencies (ubuntu only)
51+
if: matrix.platform == 'ubuntu-latest'
52+
run: |
53+
sudo apt-get update
54+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
55+
- name: Rust cache
56+
uses: swatinem/rust-cache@v2
57+
with:
58+
workspaces: './src-tauri -> target'
59+
- name: install frontend dependencies
60+
run: pnpm install --frozen-lockfile
61+
- name: lint
62+
run: |
63+
pnpm lint
64+
pnpm check
65+
- uses: tauri-apps/tauri-action@v0
66+
env:
67+
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
68+
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
with:
71+
args: ${{ matrix.args }}
72+
- name: Archive executable
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: ${{matrix.platform-name}}-${{ matrix.platform }}-${{ github.sha }}
76+
path: |
77+
src-tauri/target/release/bundle
78+
src-tauri/target/release/**/Wombat*
79+
src-tauri/target/universal-apple-darwin/**/release/**/Wombat*
80+
test-tauri-arh:
81+
strategy:
82+
fail-fast: false
83+
matrix:
84+
include:
85+
- platform: 'macos-latest' # for Univrsal based macs.
86+
args: '--verbose --target universal-apple-darwin --features arh'
87+
platform-name: 'Macos-Universal'
88+
- platform: 'ubuntu-latest' # for Tauri v1 you could replace this with ubuntu-20.04.
89+
args: '--verbose --features arh'
90+
platform-name: 'Linux'
91+
- platform: 'windows-latest'
92+
args: '--verbose --features arh'
2493
platform-name: 'Windows'
2594
runs-on: ${{ matrix.platform }}
2695
steps:

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ jobs:
7979
# args: '--verbose --target x86_64-apple-darwin'
8080
# platform-name: 'Macos-Intel'
8181
- platform: 'macos-latest' # for Univrsal based macs.
82-
args: '--verbose --target universal-apple-darwin'
82+
args: '--verbose --target universal-apple-darwin --features aws-sdk'
8383
platform-name: 'Macos-Universal'
8484
- platform: 'ubuntu-latest' # for Tauri v1 you could replace this with ubuntu-20.04.
85-
args: '--verbose'
85+
args: '--verbose --features aws-sdk'
8686
platform-name: 'Linux'
8787
- platform: 'windows-latest'
88-
args: '--verbose'
88+
args: '--verbose --features aws-sdk'
8989
platform-name: 'Windows'
9090
runs-on: ${{ matrix.platform }}
9191
steps:

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ _This project is no longer generic tool to use AWS._
2828

2929
Install caching wrapper: `brew install sccache`
3030
Export environment variable: `RUSTC_WRAPPER=sccache`
31+
Running with feature: `pnpm tauri dev -- --features arh`
3132

3233
## Expected aws configuration
3334

arh/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# ARH - AWS Request Handler
2+
3+
Compiling aws-sdk in rust, especially aws-sdk-ec2 takes ages. Decided to expsoe it via go api that compiles really fast. gRPC is plenty fast and has nice schema definition. Should be good enough :)
4+
5+
## Setup
6+
7+
```
8+
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
9+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
10+
```
11+
12+
## Generate
13+
14+
```
15+
protoc --go_out=. --go_opt=paths=source_relative \
16+
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
17+
internal/schema/schema.proto
18+
```

arh/cmd/grpc-server/main.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"net"
7+
8+
arh "github.com/dwilkolek/wombat/arh/internal/grpc"
9+
"github.com/dwilkolek/wombat/arh/proto"
10+
"google.golang.org/grpc"
11+
)
12+
13+
func main() {
14+
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", 6666))
15+
if err != nil {
16+
log.Fatalf("failed to listen: %v", err)
17+
}
18+
s := grpc.NewServer()
19+
proto.RegisterArhServer(s, arh.NewServer())
20+
log.Printf("server listening at %v", lis.Addr())
21+
if err := s.Serve(lis); err != nil {
22+
log.Fatalf("failed to serve: %v", err)
23+
}
24+
}

arh/go.mod

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module github.com/dwilkolek/wombat/arh
2+
3+
go 1.23.3
4+
5+
require (
6+
golang.org/x/net v0.30.0 // indirect
7+
golang.org/x/sys v0.26.0 // indirect
8+
golang.org/x/text v0.19.0 // indirect
9+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
10+
google.golang.org/grpc v1.69.2 // indirect
11+
google.golang.org/protobuf v1.35.1 // indirect
12+
)

arh/go.sum

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
2+
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
3+
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
4+
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
5+
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
6+
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
7+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
8+
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
9+
google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU=
10+
google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
11+
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
12+
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=

arh/internal/grpc/server.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package grpc
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"log"
7+
8+
pb "github.com/dwilkolek/wombat/arh/proto"
9+
)
10+
11+
type server struct {
12+
pb.UnsafeArhServer
13+
}
14+
15+
func NewServer() *server {
16+
return &server{}
17+
}
18+
19+
func (s *server) DescribeBastions(_ context.Context, in *pb.DescribeBastionsRequest) (*pb.DescribeBastionsResponse, error) {
20+
log.Printf("Received: %v", in)
21+
var instances []*pb.BastionInstance
22+
for env, name := range pb.Environment_name {
23+
instances = append(instances, &pb.BastionInstance{
24+
InstanceId: fmt.Sprintf("Instance Id %s", name),
25+
Env: pb.Environment(env),
26+
})
27+
}
28+
return &pb.DescribeBastionsResponse{
29+
Results: []*pb.BastionInstance{
30+
&pb.BastionInstance{
31+
InstanceId: "Instance Id DEV",
32+
Env: pb.Environment_DEV,
33+
},
34+
},
35+
}, nil
36+
}

0 commit comments

Comments
 (0)