Add common_test.go in the utils package #2276
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: CI | |
on: # yamllint disable-line rule:truthy | |
pull_request: # yamllint disable-line rule:empty-values | |
jobs: | |
lint-receptor: | |
name: lint-receptor | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: v1.52 | |
lint-receptorctl: | |
name: lint-receptorctl | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup up python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- 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@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- uses: actions/cache@v3 | |
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 | |
run: make test | |
- 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@v3 | |
if: ${{ failure() }} | |
with: | |
name: test-logs | |
path: /tmp/receptor-testing | |
- name: Archive receptor binary | |
uses: actions/upload-artifact@v3 | |
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@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download receptor | |
uses: actions/download-artifact@v3 | |
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@v4 | |
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@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- 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 |