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

Add Golang-CI and refactor integration tests #228

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
74 changes: 21 additions & 53 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ workflows:
- test:
requires:
- clean-code
- race:
requires:
- clean-code
- compile:
requires:
- clean-code
Expand All @@ -27,6 +24,7 @@ workflows:
jobs:
- compile
- image

#TODO: Utilize CircleCI caching for at least the kernel tarball
jobs:
clean-code:
Expand All @@ -38,16 +36,6 @@ jobs:
- run:
name: Install ineffassign
command: go get github.com/gordonklaus/ineffassign
- run:
name: Install Task
command: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- run:
name: Create test key
command: |
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f config/ssh_keys
touch i_agree_to_the_acme_terms
echo qemu-virt-a72 > TARGET
task config:generate
- run:
name: vet
command: go vet $(go list ./...)
Expand All @@ -67,10 +55,8 @@ jobs:
name: Install Task
command: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- run:
name: Create test key
name: Generate config
command: |
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f config/ssh_keys
touch i_agree_to_the_acme_terms
echo qemu-virt-a72 > TARGET
task config:generate
- run:
Expand All @@ -79,24 +65,8 @@ jobs:
- run:
name: Test coverage
command: task coverage
race:
docker:
- image: cimg/go:1.17.1
working_directory: ~/go/src/github.com/u-root/u-bmc
steps:
- checkout
- run:
name: Install Task
command: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- run:
name: Create test key
command: |
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f config/ssh_keys
touch i_agree_to_the_acme_terms
echo qemu-virt-a72 > TARGET
task config:generate
- run:
name: Race detector
name: Test race conditions
command: task race
compile:
docker:
Expand All @@ -108,11 +78,9 @@ jobs:
name: Install Task
command: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- run:
name: Create test key
name: Generate config
command: |
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f config/ssh_keys
touch i_agree_to_the_acme_terms
echo qemu-virt-a72 > TARGET
echo qemu-virt-a7 > TARGET
task config:generate
- run:
name: build all commands
Expand Down Expand Up @@ -149,11 +117,10 @@ jobs:
sudo make install
sudo ln -sf /usr/local/bin/mkfs.erofs /usr/bin/mkfs.erofs
- run:
name: Create test key
name: Generate config
command: |
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f config/ssh_keys
touch i_agree_to_the_acme_terms
echo qemu-virt-a72 > TARGET
task config:generate
- run:
name: Build image
command: task build
Expand All @@ -163,16 +130,17 @@ jobs:
- store_artifacts:
path: build/linux/zImage.boot
destination: zImage.boot
- run:
name: Run integration tests
command: task integration
- store_artifacts:
path: integration/serial
- run:
name: Copy failed integration tests
command: |
mkdir /tmp/integration-data/
tar -cvf /tmp/integration-data/integration.tar /tmp/ubmc-integration*/
when: on_fail
- store_artifacts:
path: /tmp/integration-data/
#TODO(MDr164): Fix integration tests uinit
# - run:
# name: Run integration tests
# command: task integration
# - store_artifacts:
# path: integration/serial
# - run:
# name: Copy failed integration tests
# command: |
# mkdir /tmp/integration-data/
# tar -cvf /tmp/integration-data/integration.tar /tmp/ubmc-integration*/
# when: on_fail
# - store_artifacts:
# path: /tmp/integration-data/
33 changes: 0 additions & 33 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '43 8 * * 0'
Expand All @@ -33,39 +21,18 @@ jobs:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
34 changes: 34 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: golangci-lint

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.17.x' ]
steps:
- uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v2
- name: Install TASK
run: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- name: Generate config
run: |
echo qemu-virt-a72 > TARGET
task config:generate
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.42.1
skip-go-installation: true
11 changes: 4 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
build/*
.task/*
i_agree_to_the_acme_terms
TARGET
config/ssh_keys.pub
config/ssh_keys.go
config/version.go
config/acme.go
config/sim_pebble.go
config/generate/ssh-pubkeys
config/generate/sim-pebble.crt
config/generate/sim-pebble.key
config/sim-pebble.crt
config/sim-pebble.key
**/.bb
config/generated.go
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,16 @@ git clone https://github.com/u-root/u-bmc

Setup configuration:
```
# SSH ECDSA public keys does not work for now
# RSA keys will be considered legacy and support will be added again later

cp ~/.ssh/*.pub config/ssh_keys.pub
cp ~/.ssh/*.pub config/generate/ssh-pubkeys

# Agree to the terms of the configured ACME server
# By default it's just a toy ACME server so this is fine, but if you're
# using another ACME server like Let's Encrypt (LE) ensure you agree to their terms.
# For LE, you can find them at https://letsencrypt.org/repository/.

touch i_agree_to_the_acme_terms
task config:generate
task config:generate -- acme
```

Build image:
Expand Down Expand Up @@ -176,7 +175,7 @@ go install github.com/u-root/u-bmc/cmd/ubmcctl
# The root CA is regenerated every time pebble is started to prevent
# testing to accidentally become production

curl https://localhost:14000/root --cacert config/sim-pebble.crt > root.crt
curl https://localhost:14000/root --cacert config/generate/sim-pebble.crt > root.crt
echo '127.0.1.2 ubmc.example.com' | sudo tee -a /etc/hosts
SSL_CERT_FILE=root.crt ubmcctl -host ubmc.example.com:6443
```
Expand Down
10 changes: 4 additions & 6 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ tasks:
cmds:
- echo "Wiping the whole build directory and config files!"
- rm -rf build/
- rm -f config/acme.go
- rm -f config/version.go
- rm -f config/sim_pebble.go
- rm -f config/generated.go
- rm -f config/sim-pebble.crt
- rm -f config/sim-pebble.key
- rm -f config/ssh_keys.go
- rm -f config/ssh_keys.pub
- rm -f i_agree_to_the_acme_terms
- rm -f config/generate/sim-pebble.crt
- rm -f config/generate/sim-pebble.key
- rm -f config/generate/ssh-pubkeys
- rm -f TARGET
- echo "Done!"

Expand Down
11 changes: 0 additions & 11 deletions config/acme.go.tmpl

This file was deleted.

12 changes: 5 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ var DefaultConfig = &Config{
{Protocol: "udp", Address: "roughtime.int80h.com:2002", PublicKeyType: ttime.KEY_TYPE_ED25519, PublicKey: "AW5uAoTSTDfG5NfY1bTh08GUnOqlRb+HVhbJ3ODJvsE="},
},

// Enable this to have the SSH server start on bootup.
// This is useful if you're debugging startup problems in u-bmc.
// NOTE: The SSH server starts before trusted time has been acquired,
// do not use in production environments.
StartDebugSshServer: true,
// authorizedKeys is generated by the Makefile
StartDebugSshServer: debugSSH,

// authorizedKeys is being read by the compiler using go embed
DebugSshServerKeys: authorizedKeys,

Version: Version{
Expand All @@ -73,9 +73,8 @@ var DefaultConfig = &Config{
},
}

const (
// Source: https://letsencrypt.org/certs/letsencryptauthorityx3.pem.txt
letsEncryptAPICA = `
// Source: https://letsencrypt.org/certs/letsencryptauthorityx3.pem.txt
const letsEncryptAPICA = `
-----BEGIN CERTIFICATE-----
MIIFjTCCA3WgAwIBAgIRANOxciY0IzLc9AUoUSrsnGowDQYJKoZIhvcNAQELBQAw
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
Expand Down Expand Up @@ -109,4 +108,3 @@ PB0t6JzUA81mSqM3kxl5e+IZwhYAyO0OTg3/fs8HqGTNKd9BqoUwSRBzp06JMg5b
rUCGwbCUDI0mxadJ3Bz4WxR6fyNpBK2yAinWEsikxqEt
-----END CERTIFICATE-----
`
)
6 changes: 6 additions & 0 deletions config/generate/debug_ssh.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:build debugssh
// +build debugssh

package main

var debugSSH = true
Loading