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

Github Actions use Google Credentials #1140

Merged
merged 4 commits into from Aug 10, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Expand Up @@ -41,3 +41,4 @@ jobs:
secrets:
REPO_READ_TOKEN: ${{ secrets.REPO_READ_TOKEN }}
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
ARTIFACT_READ_ONLY_GCP_CREDENTIALS: ${{ secrets.ARTIFACT_READ_ONLY_GCP_CREDENTIALS }}
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Expand Up @@ -23,6 +23,7 @@ jobs:
secrets:
REPO_READ_TOKEN: ${{ secrets.REPO_READ_TOKEN }}
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
ARTIFACT_READ_ONLY_GCP_CREDENTIALS: ${{ secrets.ARTIFACT_READ_ONLY_GCP_CREDENTIALS }}

appimage:
needs: test
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pullrequest.yml
Expand Up @@ -20,6 +20,7 @@ jobs:
secrets:
REPO_READ_TOKEN: ${{ secrets.REPO_READ_TOKEN }}
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
ARTIFACT_READ_ONLY_GCP_CREDENTIALS: ${{ secrets.ARTIFACT_READ_ONLY_GCP_CREDENTIALS }}

# This lets people add an "appimage" tag to have appimages built for the PR
appimage:
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/test.yml
Expand Up @@ -8,9 +8,12 @@ on:
required: true
GIT_ACCESS_TOKEN:
required: true
ARTIFACT_READ_ONLY_GCP_CREDENTIALS:
required: true

env:
GOPRIVATE: "github.com/viamrobotics/*,go.viam.com/*"
GOOGLE_APPLICATION_CREDENTIALS_FILENAME: "google-credentials.json"

jobs:
build_and_test:
Expand Down Expand Up @@ -38,6 +41,12 @@ jobs:
with:
fetch-depth: 2

- name: Create GCP Credential File from secret
run: |
GOOGLE_APPLICATION_CREDENTIALS=`pwd`/${GOOGLE_APPLICATION_CREDENTIALS_FILENAME}
echo "${{ secrets.ARTIFACT_READ_ONLY_GCP_CREDENTIALS }}" >> ${GOOGLE_APPLICATION_CREDENTIALS}
echo "GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS}" >> $GITHUB_ENV

- name: Configure git for private repos
run: |
sudo -u testbot bash -lc 'echo "machine github.com login viambot password ${{ secrets.REPO_READ_TOKEN }}" > ~/.netrc'
Expand All @@ -59,7 +68,7 @@ jobs:
- name: Test
if: matrix.platform == 'linux/amd64'
run: |
sudo -u testbot bash -lc 'make cover test-web'
sudo --preserve-env=GOOGLE_APPLICATION_CREDENTIALS -u testbot bash -lc 'make cover test-web'

- name: Code Coverage Summary Report
if: matrix.platform == 'linux/amd64'
Expand Down Expand Up @@ -100,6 +109,12 @@ jobs:
with:
fetch-depth: 2

- name: Create GCP Credential File from secret
run: |
GOOGLE_APPLICATION_CREDENTIALS=`pwd`/${GOOGLE_APPLICATION_CREDENTIALS_FILENAME}
echo "${{ secrets.ARTIFACT_READ_ONLY_GCP_CREDENTIALS }}" >> ${GOOGLE_APPLICATION_CREDENTIALS}
echo "GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS}" >> $GITHUB_ENV

- name: Clean
run: make clean-all

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -66,3 +66,6 @@ bin/

# exclude files from `ag` search
.ignore

# exclude credential created during CI
google-credentials.json
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -77,7 +77,7 @@ test-web: build-web
# test.short skips tests requiring external hardware (motors/servos)
test-pi:
go test -c -o $(BIN_OUTPUT_PATH)/test-pi go.viam.com/rdk/component/board/pi/impl
sudo $(BIN_OUTPUT_PATH)/test-pi -test.short -test.v
sudo --preserve-env=GOOGLE_APPLICATION_CREDENTIALS $(BIN_OUTPUT_PATH)/test-pi -test.short -test.v

server:
go build $(LDFLAGS) -o $(BIN_OUTPUT_PATH)/server web/cmd/server/main.go
Expand Down