Skip to content

Commit b80c098

Browse files
Add build instructions (#163)
* add build instructions --------- Co-authored-by: Ethan Heilman <ethan.r.heilman@gmail.com>
1 parent 3180040 commit b80c098

File tree

6 files changed

+126
-19
lines changed

6 files changed

+126
-19
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ dist/
3434

3535
# Created by integration tests
3636
test/integration/testfile.txt
37+
38+
# Go build cache
39+
.cache
40+
.mod-cache

CONTRIBUTING.md

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
# Contributing to OpenPubkey
1+
# Contributing to OPKSSH
22

33
Welcome to OpenPubkey SSH! We are so excited you are here. Thank you for your interest in contributing your time and expertise to the project. The following document details contribution guidelines.
44

5-
# Getting Started
5+
OPKSSH is part of [the OpenPubkey project.](https://github.com/openpubkey/openpubkey/blob/main/CONTRIBUTING.md)
6+
7+
## Getting Started
68

79
Whether you're addressing an open issue (or filing a new one), fixing a typo in our documentation, adding to core capabilities of the project, or introducing a new use case, anyone from the community is welcome here at OpenPubkey.
810

9-
## Include Licensing at the Top of Each File
11+
### Include Licensing at the Top of Each File
1012

1113
At the top of each file in your commit, please ensure the following is captured in a comment:
1214

1315
` SPDX-License-Identifier: Apache-2.0 `
1416

15-
## Sign Off on Your Commits
17+
### Sign Off on Your Commits
1618

1719
Contributors are required to sign off on their commits. A sign off certifies that you wrote the associated change or have permission to submit it as an open-source patch. All submissions are bound by the [Developer's Certificate of Origin 1.1](https://developercertificate.org/) and [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
1820

@@ -50,7 +52,8 @@ Then, you can create a signed off commit using the flag `-s` or `--signoff`:
5052
`$ git commit -s -m "This is my signed off commit."`.
5153

5254
To verify that your commit was signed off, check your latest log output:
53-
```
55+
56+
```bash
5457
$ git log -1
5558
commit <commit id>
5659
Author: Jane Doe <jane.doe@example.com>
@@ -61,7 +64,7 @@ Date: Thurs Nov 9 06:14:13 2023 -0400
6164
Signed-off-by: Jane Doe <jane.doe@example.com>
6265
```
6366

64-
## Pull Request (PR) Process
67+
### Pull Request (PR) Process
6568

6669
OpenPubkey is managed from the `main` branch. To ensure your contribution is reviewed, all pull requests must be made against the `main` branch.
6770

@@ -75,17 +78,31 @@ Our automated PR checks verify that:
7578
2. The code has been formatted correctly, according to `go fmt`.
7679
3. There are no obvious errors, according to `go vet`.
7780

78-
## Testing OpenPubkey Locally
81+
## Building and Testing
82+
83+
To build with docker run `./hack/build.sh`
7984

80-
To build OpenPubkey, ensure you have Go version `>= 1.23` installed. To verify which version you have installed, try `go version`.
85+
To build natively run
8186

82-
To run the [Google example](https://github.com/openpubkey/openpubkey/tree/main/examples/google):
83-
1. Navigate to the `examples/google/` directory.
84-
2. Execute `go build`
85-
3. Execute `./google login` to generate a valid PK token using Google as your OIDC provider.
86-
4. Execute `./google sign` to use the PK token generated in (3) to sign a verifiable message.
87+
```bash
88+
CGO_ENABLED=false go build -v -o opkssh
8789

88-
## Integration Tests
90+
chmod u+x opkssh
91+
```
92+
93+
### Unit Tests
94+
95+
```bash
96+
go test -v ./...
97+
```
98+
99+
or
100+
101+
```bash
102+
./hack/unit-tests.sh
103+
```
104+
105+
### Integration Tests
89106

90107
To run the integration tests, you need
91108
[Docker installed](https://docs.docker.com/engine/install/)
@@ -100,8 +117,14 @@ Then run the integration tests with:
100117
export OS_TYPE="ubuntu"
101118
go test -tags=integration ./test/integration -timeout=15m -count=1 -v
102119
```
120+
121+
or
103122

104-
## Building and Packaging `opkssh` Locally
123+
```bash
124+
./hack/integration-tests.sh
125+
```
126+
127+
## Packaging `opkssh` Locally
105128

106129
`opkssh` leverages on [GoReleaser](https://goreleaser.com/) to simplify the process of building binaries for all supported systems and architectures, as well as creating distribution packages.
107130

@@ -132,21 +155,21 @@ Releasing `opkssh` is a straightforward process. If you have the appropriate rol
132155

133156
Once the draft release is created, review and update it if necessary. If everything looks good, publish the release to make it available to the community.
134157

135-
# Contributing Roles
158+
## Contributing Roles
136159

137160
Contributors include anyone in the technical community who contributes code, documentation, or other technical artifacts to the OpenPubkey project.
138-
139161
Committers are Contributors who have earned the ability to modify (“commit”) source code, documentation or other technical artifacts in a project’s repository. Note that Committers are still required to submit pull requests.
140162

141163
A Contributor may become a Committer by a majority approval of the existing Committers. A Committer may be removed by a majority approval of the other existing Committers.
142164

143-
# Current Committers
165+
### Current Committers
144166

145167
The Committers of OpenPubkey are:
168+
146169
1. Ethan Heilman (@EthanHeilman)
147170
2. Jonny Stoten (@jonnystoten)
148171
3. Lucie Mugnier (@lgmugnier)
149172

150-
# Copyright
173+
## Copyright
151174

152175
By contributing to this repository, you agree to license your work under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). Any work contributed where you are not the original author must display a license header with the original author(s) and source.

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,39 @@ opkssh add root alice@example.com https://authentik.local/application/o/opkssh/
453453

454454
Do not use Confidential/Secret mode **only** client ID is needed.
455455

456+
## Developing
457+
458+
For a complete developers guide see [CONTRIBUTING.md](CONTRIBUTING.md)
459+
460+
### Building
461+
462+
Run:
463+
464+
```bash
465+
CGO_ENABLED=false go build -v -o opkssh
466+
chmod u+x opkssh
467+
```
468+
469+
to build with docker run:
470+
471+
```bash
472+
./hack/build.sh
473+
```
474+
475+
### Testing
476+
477+
For unit tests run
478+
479+
```bash
480+
go test ./...
481+
```
482+
483+
For integration tests run:
484+
485+
```bash
486+
./hack/integration-tests.sh
487+
```
488+
456489
## More information
457490

458491
We document how to manually install opkssh on a server [here](scripts/installing.md).

hack/build.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
4+
5+
set -eou pipefail
6+
7+
pushd $SCRIPT_DIR/../
8+
9+
GO_VERSION=${GO_VERSION:-"1.24.2"}
10+
11+
mkdir -p .cache
12+
mkdir -p .mod-cache
13+
14+
docker run --rm \
15+
-v "$PWD":/data/ \
16+
-w /data \
17+
--user=$(id -g):$(id -g) \
18+
-v ${PWD}/.cache:/.cache \
19+
-v ${PWD}/.mod-cache:/go/pkg/mod \
20+
golang:${GO_VERSION}-alpine \
21+
go build -v -o opkssh
22+
23+
chmod u+x opkssh
24+
25+
popd

hack/integration-tests.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -eou pipefail
4+
5+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6+
7+
pushd $SCRIPT_DIR/../
8+
9+
OS_TYPE=ubuntu go test -tags=integration ./test/integration -timeout=15m -count=1 -parallel=2 -v
10+
11+
popd

hack/unit-tests.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -eou pipefail
4+
5+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6+
7+
pushd $SCRIPT_DIR/../
8+
9+
go test -v ./...
10+
11+
popd

0 commit comments

Comments
 (0)