Skip to content

Add unit tests for framer.go #2133

Add unit tests for framer.go

Add unit tests for framer.go #2133

Workflow file for this run

---
name: CI
on:
pull_request:
jobs:
lint-receptor:
name: lint-receptor
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.52
lint-receptorctl:
name: lint-receptorctl
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup up python
uses: actions/setup-python@v2
- name: Install tox
run: pip install tox
- name: Run receptorctl linters
run: make receptorctl-lint
receptor:
name: receptor (Go ${{ matrix.go-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ["1.19", "1.20"]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: build and install receptor
run: |
make build-all
sudo cp ./receptor /usr/local/bin/receptor
- name: Download kind binary
run: curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64 && chmod +x ./kind
- name: Create k8s cluster
run: ./kind create cluster
- name: Interact with the cluster
run: kubectl get nodes
- name: Run receptor tests with coverage
run: make coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: get k8s logs
if: ${{ failure() }}
run: .github/workflows/artifact-k8s-logs.sh
- name: remove sockets before archiving logs
if: ${{ failure() }}
run: find /tmp/receptor-testing -name controlsock -delete
- name: Artifact receptor data
uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: test-logs
path: /tmp/receptor-testing
- name: Archive receptor binary
uses: actions/upload-artifact@v2
with:
name: receptor
path: /usr/local/bin/receptor
receptorctl:
name: receptorctl (Python ${{ matrix.python-version }})
needs: receptor
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download receptor
uses: actions/download-artifact@v2
with:
name: receptor
path: /usr/local/bin/
- name: Fix permissions on receptor binary
run: sudo chmod a+x /usr/local/bin/receptor
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: pip install tox
- name: Run receptorctl tests
run: make receptorctl-test
container:
name: container
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
- name: Install python dependencies
run: pip install build
- name: Build container
run: make container REPO=receptor LATEST=yes
- name: Write out basic config
run: |
cat << EOF > test.cfg
---
- local-only:
- control-service:
service: control
filename: /tmp/receptor.sock
- work-command:
worktype: cat
command: cat
EOF
- name: Run receptor (and wait a few seconds for it to boot)
run: |
podman run --name receptor -d -v $PWD/test.cfg:/etc/receptor/receptor.conf:Z localhost/receptor
sleep 3
podman logs receptor
- name: Submit work and assert the output we expect
run: |
output=$(podman exec -i receptor receptorctl work submit cat -l 'hello world' -f)
echo $output
if [[ "$output" != "hello world" ]]; then
echo "Output did not contain expected value"
exit 1
fi