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

Replace .netrc with Env Var in Dockerfile #134

Merged
merged 3 commits into from
Dec 14, 2023
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
16 changes: 4 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
env:
GOPRIVATE: github.com/sedaprotocol/vrf-go
PAT: ${{ secrets.PAT }}
GITHUB_TOKEN: ${{ secrets.PAT }}
strategy:
matrix:
arch: [amd64, arm64]
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
if: steps.cache-binaries.outputs.cache-hit != 'true' && env.GIT_DIFF
run: |
go mod download
make build
make build

tests:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -93,32 +93,24 @@ jobs:
with:
name: "${{ github.sha }}-${{ matrix.part }}-coverage"
path: ./${{ matrix.part }}profile.out

test-e2e:
runs-on: ubuntu-latest
env:
GOPRIVATE: github.com/sedaprotocol/vrf-go
USERNAME: hacheigriega
PAT: ${{ secrets.PAT }}
GITHUB_TOKEN: ${{ secrets.PAT }}
timeout-minutes: 10
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.21"
- uses: actions/checkout@v4
- run: git config --global url.https://${GITHUB_TOKEN}@github.com/.insteadOf https://github.com/
- uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Create .netrc file
run: |
echo "machine github.com" > ${GITHUB_WORKSPACE}/.netrc
echo " login ${USERNAME}" >> ${GITHUB_WORKSPACE}/.netrc
echo " password ${PAT}" >> ${GITHUB_WORKSPACE}/.netrc
chmod 600 ${GITHUB_WORKSPACE}/.netrc
- name: Test e2e
run: |
make test-e2e
37 changes: 26 additions & 11 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Otherwise please see the [dev dependencies](#dev-dependencies).
## Dev Dependencies

### [clang-format](https://clang.llvm.org/docs/ClangFormat.html)

We use clang format to format our protobuf generated code.

- Linux
Expand All @@ -25,7 +26,9 @@ We use clang format to format our protobuf generated code.
- Using [macports](https://www.macports.org/): `sudo port install clang-format`

# TODO don't rely on docker for this

### [docker](https://www.docker.com/)

Docker is used to help make release and static builds locally.

- Linux
Expand All @@ -35,20 +38,24 @@ Docker is used to help make release and static builds locally.
- Using [macports](https://www.macports.org/): `sudo port install docker`

### [Golang](https://go.dev/)

We use Golang as the language to develop `seda-chaind` as it has the [CosmosSDK](https://v1.cosmos.network/sdk).

- [Golang](https://go.dev/dl/): you can download it from the linked page or:
- Linux: Use your distribution's packagae manager.
- Mac: Use `macports` or `brew`.
- Linux: Use your distribution's packagae manager.
- Mac: Use `macports` or `brew`.
- Ensure that `$GOPATH` and `$PATH` have been set properly. On a Mac that uses the Z shell, you may have to run the following:

```zsh
mkdir -p $HOME/go/bin
echo "export GOPATH=$HOME/go" >> ~/.zprofile
echo "export PATH=\$PATH:\$GOPATH/bin" >> ~/.zprofile
echo "export GO111MODULE=on" >> ~/.zprofile
source ~/.zprofile
```

### [make](https://www.gnu.org/software/make/)

We use GNU Make to help us built, lint, fmt, and etc for our project.

- Linux:
Expand All @@ -59,7 +66,9 @@ We use GNU Make to help us built, lint, fmt, and etc for our project.
- Otherwise use [brew](https://brew.sh/) or [macports](https://www.macports.org/) to install it.

<!-- It actually uses docker to run protobuf commmands... this should be fixed -->

### [Protobuf](https://protobuf.dev/)

A necessary tool for generating protobuf code.

- Linux:
Expand All @@ -69,9 +78,11 @@ A necessary tool for generating protobuf code.
- Using [macports](https://www.macports.org/): `sudo port install protobuf-cpp`

#### Protobuf Sub-Deps

We also need some dependencies to make protobuf work for cosmos.

##### Buf

The `buf` tool.

- Linux:
Expand All @@ -81,35 +92,41 @@ The `buf` tool.
- Using [macports](https://www.macports.org/): `sudo port install buf`

### [WasmVM](https://github.com/CosmWasm/wasmvm)

WasmVM is the library that makes CosmWASM possible.

You can install that by running:

```bash
sudo ./scripts/install_wasmvm.sh
```

## Building using Make

To build the protobuf(only necessary if you change the protobuf) you will need to run,:

```bash
make prot-dep-install
make proto-update-deps
make proto-gen
```

To build, run:

```bash
make build
```

To install (builds and moves the executable to `$GOPATH/bin`, which should be in `$PATH`), run:

```bash
make install
```

## Running a Single-node Local Testnet

To run a single-node testnet locally:

```bash
make build
BIN=./build/seda-chaind
Expand All @@ -128,17 +145,20 @@ $BIN start
## Linting & Formatting

To lint and format the protobuf(only necessary if you mess with protobuf):

```bash
make proto-fmt
make proto-lint
```

If you have not install a Go linters runner, install it first:

```bash
make lint-install
```

Run format and run linter for go sided:

```bash
make fmt
make lint
Expand All @@ -151,24 +171,19 @@ After running the `make install` command you should be able to use `seda-chaind
## Testing

To run all unit tests:

```bash
make test-unit
```

To see test coverage:

```bash
make cover-html
```

To run end-to-end tests, you first need to create a file `.netrc` containing GitHub credentials in the project root. This enables an access to the private repositories during the Docker build process. The `.netrc` file should look as follows:
```bash
machine github.com
login <YOUR_USERNAME>
password <YOUR_GITHUB_TOKEN>
```
To run end-to-end tests:

Change the permissions of `.netrc` and run e2e with the following commands:
```bash
chmod 600 .netrc
make test-e2e
GITHUB_TOKEN=<your_github_pat> make test-e2e
```
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ cover-html: test-unit-cover

docker-build-e2e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can add a ifdef GITHUB_TOKEN... clause to echo an error message if GITHUB_TOKEN is empty?

@docker build \
--build-arg GITHUB_TOKEN=$(GITHUB_TOKEN) \
-t sedaprotocol/seda-chaind-e2e \
-f dockerfiles/Dockerfile.e2e .

Expand Down
8 changes: 5 additions & 3 deletions dockerfiles/Dockerfile.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ FROM golang:${GO_VERSION}-alpine as builder

ARG GIT_VERSION
ARG GIT_COMMIT
ARG GITHUB_TOKEN

RUN apk add --no-cache \
ca-certificates \
Expand All @@ -19,11 +20,12 @@ RUN apk add --no-cache \
git

# Download go dependencies
COPY .netrc /root/
RUN chmod 600 /root/.netrc

WORKDIR /seda-chain
COPY go.mod go.sum ./

# Configure Git to use the PAT for authentication
RUN git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"

RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download
Expand Down
Loading