Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Szakacs <[email protected]>
  • Loading branch information
alltilla committed Mar 25, 2024
1 parent edcd82b commit fe291ab
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 83 deletions.
162 changes: 81 additions & 81 deletions .github/workflows/syslog-ng-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,84 +25,84 @@ on:
- cron: '00 23 * * *'

jobs:
tarball:
name: create-source-tarball
runs-on: ubuntu-latest
outputs:
snapshot-version: ${{ steps.snapshot-version.outputs.SNAPSHOT_VERSION }}
steps:
- name: Checkout syslog-ng source
uses: actions/checkout@v4
with:
repository: ${{ inputs.repo || 'syslog-ng/syslog-ng' }}
ref: ${{ inputs.ref || 'master' }}
fetch-depth: 0

- name: Prepare docker image
run: ./dbld/rules cache-image-tarball

- name: Create source tarball
run: ./dbld/rules pkg-tarball

- name: Determine snapshot version
id: snapshot-version
run: |
tarball_filename="$(find dbld/build -name '*.tar.*' -printf '%f\n')"
tarball_name="${tarball_filename/\.tar.*}"
tarball_version="${tarball_name/syslog-ng-}"
pkg_version="$(echo $tarball_version | sed -E 's|(([0-9]+\.){2}[0-9]+).*|\1|')_git$(date +%Y%m%d)"
echo "SNAPSHOT_VERSION=${pkg_version}" >> $GITHUB_OUTPUT
- name: Store source tarball as artifact
uses: actions/upload-artifact@v4
with:
name: source-tarball
path: dbld/build/*.tar.*

build-and-test:
runs-on: ubuntu-latest
needs: tarball
steps:
- name: Checkout source
uses: actions/checkout@v4

- name: Download source tarball artifact
uses: actions/download-artifact@v4
with:
name: source-tarball
path: syslog-ng/apkbuild/axoflow/syslog-ng

- name: Build and export Docker image
uses: docker/build-push-action@v5
with:
context: syslog-ng
file: syslog-ng/alpine.dockerfile
load: true
tags: syslog-ng:test
build-args: |
PKG_TYPE=nightly
SNAPSHOT_VERSION=${{ needs.tarball.outputs.snapshot-version }}
- name: Smoke test
run: |
export SYSLOG_NG_IMAGE="syslog-ng:test"
export SYSLOG_NG_VERSION="${{ needs.tarball.outputs.snapshot-version }}"
syslog-ng/tests/smoke.sh
publish-image:
if: github.ref == 'refs/heads/main'
uses: ./.github/workflows/syslog-ng-docker.yml
needs: [tarball, build-and-test]
with:
pkg-type: nightly
tarball-artifact: source-tarball
snapshot-version: ${{ needs.tarball.outputs.snapshot-version }}
# tarball:
# name: create-source-tarball
# runs-on: ubuntu-latest
# outputs:
# snapshot-version: ${{ steps.snapshot-version.outputs.SNAPSHOT_VERSION }}
# steps:
# - name: Checkout syslog-ng source
# uses: actions/checkout@v4
# with:
# repository: ${{ inputs.repo || 'syslog-ng/syslog-ng' }}
# ref: ${{ inputs.ref || 'master' }}
# fetch-depth: 0

# - name: Prepare docker image
# run: ./dbld/rules cache-image-tarball

# - name: Create source tarball
# run: ./dbld/rules pkg-tarball

# - name: Determine snapshot version
# id: snapshot-version
# run: |
# tarball_filename="$(find dbld/build -name '*.tar.*' -printf '%f\n')"
# tarball_name="${tarball_filename/\.tar.*}"
# tarball_version="${tarball_name/syslog-ng-}"
# pkg_version="$(echo $tarball_version | sed -E 's|(([0-9]+\.){2}[0-9]+).*|\1|')_git$(date +%Y%m%d)"
# echo "SNAPSHOT_VERSION=${pkg_version}" >> $GITHUB_OUTPUT

# - name: Store source tarball as artifact
# uses: actions/upload-artifact@v4
# with:
# name: source-tarball
# path: dbld/build/*.tar.*

# build-and-test:
# runs-on: ubuntu-latest
# needs: tarball
# steps:
# - name: Checkout source
# uses: actions/checkout@v4

# - name: Download source tarball artifact
# uses: actions/download-artifact@v4
# with:
# name: source-tarball
# path: syslog-ng/apkbuild/axoflow/syslog-ng

# - name: Build and export Docker image
# uses: docker/build-push-action@v5
# with:
# context: syslog-ng
# file: syslog-ng/alpine.dockerfile
# load: true
# tags: syslog-ng:test
# build-args: |
# PKG_TYPE=nightly
# SNAPSHOT_VERSION=${{ needs.tarball.outputs.snapshot-version }}

# - name: Smoke test
# run: |
# export SYSLOG_NG_IMAGE="syslog-ng:test"
# export SYSLOG_NG_VERSION="${{ needs.tarball.outputs.snapshot-version }}"
# syslog-ng/tests/smoke.sh


# publish-image:
# if: github.ref == 'refs/heads/main'
# uses: ./.github/workflows/syslog-ng-docker.yml
# needs: [tarball, build-and-test]
# with:
# pkg-type: nightly
# tarball-artifact: source-tarball
# snapshot-version: ${{ needs.tarball.outputs.snapshot-version }}

# https://github.com/actions/delete-package-versions/issues/90
cleanup-old-images:
if: github.ref == 'refs/heads/main'
needs: publish-image
# if: github.ref == 'refs/heads/main'
# needs: publish-image
runs-on: ubuntu-latest
steps:
- name: Clean up old images
Expand All @@ -113,12 +113,12 @@ jobs:
const snapshotTagPattern = /_git[0-9]+/
const package_name = "axosyslog"
const org = "axoflow"
const image = `${org}/${package_name}`
const user = "alltilla"
const image = `${user}/${package_name}`
const allPackageVersions = await github.paginate(
github.rest.packages.getAllPackageVersionsForPackageOwnedByOrg,
{ package_type: "container", package_name: package_name, org: org }
github.rest.packages.getAllPackageVersionsForPackageOwnedByUser,
{ package_type: "container", package_name: package_name, user: user }
)
const oldPackageDate = new Date()
Expand Down Expand Up @@ -162,10 +162,10 @@ jobs:
return;
}
return github.rest.packages.deletePackageVersionForOrg({ package_type: "container", package_name: package_name, org: org, package_version_id: version.id})
return github.rest.packages.deletePackageVersionForUser({ package_type: "container", package_name: package_name, user: user, package_version_id: version.id})
}))
await Promise.all(oldSnapshotVersions.map((v) => {
return github.rest.packages.deletePackageVersionForOrg({ package_type: "container", package_name: package_name, org: org, package_version_id: v.id})
return github.rest.packages.deletePackageVersionForUser({ package_type: "container", package_name: package_name, user: user, package_version_id: v.id})
}))
4 changes: 2 additions & 2 deletions syslog-ng/alpine.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG DEBUG=false

FROM alpine:3.19 as apkbuilder
FROM alpine:3.18 as apkbuilder

ARG PKG_TYPE=stable
ARG SNAPSHOT_VERSION
Expand Down Expand Up @@ -35,7 +35,7 @@ RUN mkdir packages \
&& abuild -r


FROM alpine:3.19
FROM alpine:3.18

ARG DEBUG

Expand Down

0 comments on commit fe291ab

Please sign in to comment.