Skip to content

Commit

Permalink
Merge pull request #1 from testainers/dev
Browse files Browse the repository at this point in the history
Version 0.0.1.
  • Loading branch information
edufolly authored Apr 23, 2024
2 parents 38b0da1 + 109b8c5 commit 022bda9
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 1 deletion.
72 changes: 72 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI Build

on:
push:
branches: [ main ]

jobs:

build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
steps:
- name: Code Checkout
uses: actions/checkout@v4

- name: Get Version
run: |
echo "TAGS=latest" >> $GITHUB_ENV
SUFFIX=""
VERSION=$(grep 'version:' version.yaml | cut -c 10-)$SUFFIX
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "REPO=$GITHUB_REPOSITORY" >> $GITHUB_ENV
echo "OWNER=$GITHUB_REPOSITORY_OWNER" >> $GITHUB_ENV
- name: Check if version is used
run: |
URL=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/${{ env.VERSION }}
echo "$URL"
CODE=$(curl -s -o /dev/null -w "%{http_code}" "$URL")
if [ "$CODE" != 404 ]; then
echo "Release '$VERSION' already exists. ($CODE)"
exit 1
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ env.OWNER }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Docker Build & Push
uses: docker/build-push-action@v5
with:
push: true
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/386
tags: |
${{ env.REPO }}:${{ env.VERSION }}
${{ env.REPO }}:latest
- name: Creating GitHub Tag
uses: mathieudutour/github-tag-action@v6.2
with:
custom_tag: ${{ env.VERSION }}
tag_prefix: ''
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Pull Request Tests

on: [pull_request]

jobs:
#########
# Tests #
#########
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
alpine:
- 3.16
- 3.17
- 3.18
- 3.19
steps:
- name: Code Checkout
uses: actions/checkout@v4

- name: Install snmp
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update -y
sudo apt-get install snmp -y
- name: Running Tests
env:
ALPINE_VERSION: ${{ matrix.alpine }}
run: ./test.sh
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ COPY entrypoint.sh /usr/local/bin/

COPY etc/snmp/ /etc/snmp/

EXPOSE 161/udp

ENTRYPOINT ["entrypoint.sh"]
15 changes: 15 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#! /bin/bash
set -e
set -x

docker build . --no-cache -t snmpd-container-test

docker run --rm --name snmpd -p 5161:161/udp -d snmpd-container-test

sleep 2

snmpwalk -v 2c -c public localhost:5161 .

docker stop -t 1 snmpd

docker image rm snmpd-container-test
2 changes: 1 addition & 1 deletion version.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: 0.0.0
version: 0.0.1

0 comments on commit 022bda9

Please sign in to comment.