parent
fd8050e7e5
commit
b807117f5f
@ -0,0 +1,26 @@
|
||||
From 6b6f61668c539329bc95fb7f3c3b644b793dfb52 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Wed, 25 Jan 2023 18:47:05 +0100
|
||||
Subject: [PATCH] journal-def: fix type of signature to match the actual field
|
||||
in the Header structure
|
||||
|
||||
(cherry picked from commit 6fe167d0a77f72086b457125fad6931ca02a4baf)
|
||||
|
||||
Related: #2184929
|
||||
---
|
||||
src/libsystemd/sd-journal/journal-def.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-journal/journal-def.h b/src/libsystemd/sd-journal/journal-def.h
|
||||
index 8f994b0178..ab4880761b 100644
|
||||
--- a/src/libsystemd/sd-journal/journal-def.h
|
||||
+++ b/src/libsystemd/sd-journal/journal-def.h
|
||||
@@ -195,7 +195,7 @@ enum {
|
||||
#endif
|
||||
|
||||
#define HEADER_SIGNATURE \
|
||||
- ((const char[]) { 'L', 'P', 'K', 'S', 'H', 'H', 'R', 'H' })
|
||||
+ ((const uint8_t[]) { 'L', 'P', 'K', 'S', 'H', 'H', 'R', 'H' })
|
||||
|
||||
#define struct_Header__contents { \
|
||||
uint8_t signature[8]; /* "LPKSHHRH" */ \
|
@ -0,0 +1,63 @@
|
||||
From de2a4abb178021ab6700f0bc4038daf88f92cb03 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Wed, 25 Jan 2023 18:48:31 +0100
|
||||
Subject: [PATCH] journal: use compound initialization for journal file Header
|
||||
structure
|
||||
|
||||
(cherry picked from commit c3dd0dcb888fd8da7ce4e5299caf45e90ddcd41b)
|
||||
|
||||
Related: #2184929
|
||||
---
|
||||
src/libsystemd/sd-journal/journal-file.c | 23 +++++++++++------------
|
||||
1 file changed, 11 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
|
||||
index c489436a1e..cf86bab2dc 100644
|
||||
--- a/src/libsystemd/sd-journal/journal-file.c
|
||||
+++ b/src/libsystemd/sd-journal/journal-file.c
|
||||
@@ -320,9 +320,8 @@ static bool compact_mode_requested(void) {
|
||||
}
|
||||
|
||||
static int journal_file_init_header(JournalFile *f, JournalFileFlags file_flags, JournalFile *template) {
|
||||
- Header h = {};
|
||||
- ssize_t k;
|
||||
bool seal = false;
|
||||
+ ssize_t k;
|
||||
int r;
|
||||
|
||||
assert(f);
|
||||
@@ -332,16 +331,17 @@ static int journal_file_init_header(JournalFile *f, JournalFileFlags file_flags,
|
||||
seal = FLAGS_SET(file_flags, JOURNAL_SEAL) && journal_file_fss_load(f) >= 0;
|
||||
#endif
|
||||
|
||||
- memcpy(h.signature, HEADER_SIGNATURE, 8);
|
||||
- h.header_size = htole64(ALIGN64(sizeof(h)));
|
||||
-
|
||||
- h.incompatible_flags |= htole32(
|
||||
- FLAGS_SET(file_flags, JOURNAL_COMPRESS) *
|
||||
- COMPRESSION_TO_HEADER_INCOMPATIBLE_FLAG(DEFAULT_COMPRESSION) |
|
||||
- keyed_hash_requested() * HEADER_INCOMPATIBLE_KEYED_HASH |
|
||||
- compact_mode_requested() * HEADER_INCOMPATIBLE_COMPACT);
|
||||
+ Header h = {
|
||||
+ .header_size = htole64(ALIGN64(sizeof(h))),
|
||||
+ .incompatible_flags = htole32(
|
||||
+ FLAGS_SET(file_flags, JOURNAL_COMPRESS) * COMPRESSION_TO_HEADER_INCOMPATIBLE_FLAG(DEFAULT_COMPRESSION) |
|
||||
+ keyed_hash_requested() * HEADER_INCOMPATIBLE_KEYED_HASH |
|
||||
+ compact_mode_requested() * HEADER_INCOMPATIBLE_COMPACT),
|
||||
+ .compatible_flags = htole32(seal * HEADER_COMPATIBLE_SEALED),
|
||||
+ };
|
||||
|
||||
- h.compatible_flags = htole32(seal * HEADER_COMPATIBLE_SEALED);
|
||||
+ assert_cc(sizeof(h.signature) == sizeof(HEADER_SIGNATURE));
|
||||
+ memcpy(h.signature, HEADER_SIGNATURE, sizeof(HEADER_SIGNATURE));
|
||||
|
||||
r = sd_id128_randomize(&h.file_id);
|
||||
if (r < 0)
|
||||
@@ -356,7 +356,6 @@ static int journal_file_init_header(JournalFile *f, JournalFileFlags file_flags,
|
||||
k = pwrite(f->fd, &h, sizeof(h), 0);
|
||||
if (k < 0)
|
||||
return -errno;
|
||||
-
|
||||
if (k != sizeof(h))
|
||||
return -EIO;
|
||||
|
@ -0,0 +1,25 @@
|
||||
From de88fa23f060ab5f554f4c0d41b0f93430f1db8a Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Tue, 4 Apr 2023 17:11:28 +0900
|
||||
Subject: [PATCH] journald: fix log message
|
||||
|
||||
(cherry picked from commit 01aa59979bc61125f599a5b8a6c911fff5daaee7)
|
||||
|
||||
Resolves: #2184929
|
||||
---
|
||||
src/journal/journald-server.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
|
||||
index 71d7a59bda..cbcf1e9d9e 100644
|
||||
--- a/src/journal/journald-server.c
|
||||
+++ b/src/journal/journald-server.c
|
||||
@@ -2011,7 +2011,7 @@ static int vl_method_synchronize(Varlink *link, JsonVariant *parameters, Varlink
|
||||
if (json_variant_elements(parameters) > 0)
|
||||
return varlink_error_invalid_parameter(link, parameters);
|
||||
|
||||
- log_info("Received client request to rotate journal.");
|
||||
+ log_info("Received client request to sync journal.");
|
||||
|
||||
/* We don't do the main work now, but instead enqueue a deferred event loop job which will do
|
||||
* it. That job is scheduled at low priority, so that we return from this method call only after all
|
@ -0,0 +1,66 @@
|
||||
From c7919b02b504e2c0ccacf02c6f21f65c3f18ea4c Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Tue, 4 Apr 2023 16:43:44 +0900
|
||||
Subject: [PATCH] sd-journal: cache results of parsing environment variables
|
||||
|
||||
(cherry picked from commit 9dfbae203e3afa500163bc46e0070c4cb2180aac)
|
||||
|
||||
Resolves: #2184929
|
||||
---
|
||||
src/libsystemd/sd-journal/journal-file.c | 34 +++++++++++++++---------
|
||||
1 file changed, 22 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
|
||||
index cf86bab2dc..00de564499 100644
|
||||
--- a/src/libsystemd/sd-journal/journal-file.c
|
||||
+++ b/src/libsystemd/sd-journal/journal-file.c
|
||||
@@ -296,27 +296,37 @@ JournalFile* journal_file_close(JournalFile *f) {
|
||||
}
|
||||
|
||||
static bool keyed_hash_requested(void) {
|
||||
+ static thread_local int cached = -1;
|
||||
int r;
|
||||
|
||||
- r = getenv_bool("SYSTEMD_JOURNAL_KEYED_HASH");
|
||||
- if (r >= 0)
|
||||
- return r;
|
||||
- if (r != -ENXIO)
|
||||
- log_debug_errno(r, "Failed to parse $SYSTEMD_JOURNAL_KEYED_HASH environment variable, ignoring: %m");
|
||||
+ if (cached < 0) {
|
||||
+ r = getenv_bool("SYSTEMD_JOURNAL_KEYED_HASH");
|
||||
+ if (r < 0) {
|
||||
+ if (r != -ENXIO)
|
||||
+ log_debug_errno(r, "Failed to parse $SYSTEMD_JOURNAL_KEYED_HASH environment variable, ignoring: %m");
|
||||
+ cached = true;
|
||||
+ } else
|
||||
+ cached = r;
|
||||
+ }
|
||||
|
||||
- return true;
|
||||
+ return cached;
|
||||
}
|
||||
|
||||
static bool compact_mode_requested(void) {
|
||||
+ static thread_local int cached = -1;
|
||||
int r;
|
||||
|
||||
- r = getenv_bool("SYSTEMD_JOURNAL_COMPACT");
|
||||
- if (r >= 0)
|
||||
- return r;
|
||||
- if (r != -ENXIO)
|
||||
- log_debug_errno(r, "Failed to parse $SYSTEMD_JOURNAL_COMPACT environment variable, ignoring: %m");
|
||||
+ if (cached < 0) {
|
||||
+ r = getenv_bool("SYSTEMD_JOURNAL_COMPACT");
|
||||
+ if (r < 0) {
|
||||
+ if (r != -ENXIO)
|
||||
+ log_debug_errno(r, "Failed to parse $SYSTEMD_JOURNAL_COMPACT environment variable, ignoring: %m");
|
||||
+ cached = true;
|
||||
+ } else
|
||||
+ cached = r;
|
||||
+ }
|
||||
|
||||
- return true;
|
||||
+ return cached;
|
||||
}
|
||||
|
||||
static int journal_file_init_header(JournalFile *f, JournalFileFlags file_flags, JournalFile *template) {
|
@ -0,0 +1,55 @@
|
||||
From c926e4ff48022a71665e7e7833fd59a1bf2ad5fb Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Tue, 4 Apr 2023 14:34:32 +0900
|
||||
Subject: [PATCH] compress: introduce compression_supported() helper function
|
||||
|
||||
(cherry picked from commit 83f3d73da8d132773dd91aae0fa7babb74920774)
|
||||
|
||||
Resolves: #2184929
|
||||
---
|
||||
src/basic/compress.c | 10 ++++++++++
|
||||
src/basic/compress.h | 3 +++
|
||||
2 files changed, 13 insertions(+)
|
||||
|
||||
diff --git a/src/basic/compress.c b/src/basic/compress.c
|
||||
index 1e94635397..dce0ebf222 100644
|
||||
--- a/src/basic/compress.c
|
||||
+++ b/src/basic/compress.c
|
||||
@@ -66,6 +66,16 @@ static const char* const compression_table[_COMPRESSION_MAX] = {
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(compression, Compression);
|
||||
|
||||
+bool compression_supported(Compression c) {
|
||||
+ static const unsigned supported =
|
||||
+ (1U << COMPRESSION_NONE) |
|
||||
+ (1U << COMPRESSION_XZ) * HAVE_XZ |
|
||||
+ (1U << COMPRESSION_LZ4) * HAVE_LZ4 |
|
||||
+ (1U << COMPRESSION_ZSTD) * HAVE_ZSTD;
|
||||
+
|
||||
+ return c >= 0 && c < _COMPRESSION_MAX && FLAGS_SET(supported, 1U << c);
|
||||
+}
|
||||
+
|
||||
int compress_blob_xz(const void *src, uint64_t src_size,
|
||||
void *dst, size_t dst_alloc_size, size_t *dst_size) {
|
||||
#if HAVE_XZ
|
||||
diff --git a/src/basic/compress.h b/src/basic/compress.h
|
||||
index 583b105c66..2201bca74c 100644
|
||||
--- a/src/basic/compress.h
|
||||
+++ b/src/basic/compress.h
|
||||
@@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <errno.h>
|
||||
+#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -17,6 +18,8 @@ typedef enum Compression {
|
||||
const char* compression_to_string(Compression compression);
|
||||
Compression compression_from_string(const char *compression);
|
||||
|
||||
+bool compression_supported(Compression c);
|
||||
+
|
||||
int compress_blob_xz(const void *src, uint64_t src_size,
|
||||
void *dst, size_t dst_alloc_size, size_t *dst_size);
|
||||
int compress_blob_lz4(const void *src, uint64_t src_size,
|
@ -0,0 +1,115 @@
|
||||
From 3baac68b2bcad46062b12aa11e15adf8e6d80a40 Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Tue, 4 Apr 2023 18:22:50 +0900
|
||||
Subject: [PATCH] sd-journal: always use the compression algorithm specified in
|
||||
the header
|
||||
|
||||
Previously, data object may be compressed with an algorithm that is not
|
||||
mentioned in the header.
|
||||
|
||||
(cherry picked from commit 2360352ef02548723ac0c8eaf5ff6905eb9eeca5)
|
||||
|
||||
Resolves: #2184929
|
||||
---
|
||||
src/libsystemd/sd-journal/journal-file.c | 40 ++++++++++++++----------
|
||||
src/libsystemd/sd-journal/journal-file.h | 12 +++++--
|
||||
2 files changed, 33 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
|
||||
index 00de564499..1b8f0abf97 100644
|
||||
--- a/src/libsystemd/sd-journal/journal-file.c
|
||||
+++ b/src/libsystemd/sd-journal/journal-file.c
|
||||
@@ -1593,24 +1593,31 @@ static int journal_file_append_field(
|
||||
}
|
||||
|
||||
static Compression maybe_compress_payload(JournalFile *f, uint8_t *dst, const uint8_t *src, uint64_t size, size_t *rsize) {
|
||||
- Compression compression = COMPRESSION_NONE;
|
||||
-
|
||||
assert(f);
|
||||
assert(f->header);
|
||||
|
||||
#if HAVE_COMPRESSION
|
||||
- if (JOURNAL_FILE_COMPRESS(f) && size >= f->compress_threshold_bytes) {
|
||||
- compression = compress_blob(src, size, dst, size - 1, rsize);
|
||||
- if (compression > 0)
|
||||
- log_debug("Compressed data object %"PRIu64" -> %zu using %s",
|
||||
- size, *rsize, compression_to_string(compression));
|
||||
- else
|
||||
- /* Compression didn't work, we don't really care why, let's continue without compression */
|
||||
- compression = COMPRESSION_NONE;
|
||||
+ Compression c;
|
||||
+ int r;
|
||||
+
|
||||
+ c = JOURNAL_FILE_COMPRESSION(f);
|
||||
+ if (c == COMPRESSION_NONE || size < f->compress_threshold_bytes)
|
||||
+ return COMPRESSION_NONE;
|
||||
+
|
||||
+ r = compress_blob_explicit(c, src, size, dst, size - 1, rsize);
|
||||
+ if (r < 0) {
|
||||
+ log_debug_errno(r, "Failed to compress data object using %s, ignoring: %m", compression_to_string(c));
|
||||
+ /* Compression didn't work, we don't really care why, let's continue without compression */
|
||||
+ return COMPRESSION_NONE;
|
||||
}
|
||||
-#endif
|
||||
|
||||
- return compression;
|
||||
+ assert(r == c);
|
||||
+ log_debug("Compressed data object %"PRIu64" -> %zu using %s", size, *rsize, compression_to_string(c));
|
||||
+
|
||||
+ return c;
|
||||
+#else
|
||||
+ return COMPRESSION_NONE;
|
||||
+#endif
|
||||
}
|
||||
|
||||
static int journal_file_append_data(
|
||||
@@ -3887,20 +3894,21 @@ int journal_file_open(
|
||||
f->close_fd = true;
|
||||
|
||||
if (DEBUG_LOGGING) {
|
||||
- static int last_seal = -1, last_compress = -1, last_keyed_hash = -1;
|
||||
+ static int last_seal = -1, last_keyed_hash = -1;
|
||||
+ static Compression last_compression = _COMPRESSION_INVALID;
|
||||
static uint64_t last_bytes = UINT64_MAX;
|
||||
|
||||
if (last_seal != JOURNAL_HEADER_SEALED(f->header) ||
|
||||
last_keyed_hash != JOURNAL_HEADER_KEYED_HASH(f->header) ||
|
||||
- last_compress != JOURNAL_FILE_COMPRESS(f) ||
|
||||
+ last_compression != JOURNAL_FILE_COMPRESSION(f) ||
|
||||
last_bytes != f->compress_threshold_bytes) {
|
||||
|
||||
log_debug("Journal effective settings seal=%s keyed_hash=%s compress=%s compress_threshold_bytes=%s",
|
||||
yes_no(JOURNAL_HEADER_SEALED(f->header)), yes_no(JOURNAL_HEADER_KEYED_HASH(f->header)),
|
||||
- yes_no(JOURNAL_FILE_COMPRESS(f)), FORMAT_BYTES(f->compress_threshold_bytes));
|
||||
+ compression_to_string(JOURNAL_FILE_COMPRESSION(f)), FORMAT_BYTES(f->compress_threshold_bytes));
|
||||
last_seal = JOURNAL_HEADER_SEALED(f->header);
|
||||
last_keyed_hash = JOURNAL_HEADER_KEYED_HASH(f->header);
|
||||
- last_compress = JOURNAL_FILE_COMPRESS(f);
|
||||
+ last_compression = JOURNAL_FILE_COMPRESSION(f);
|
||||
last_bytes = f->compress_threshold_bytes;
|
||||
}
|
||||
}
|
||||
diff --git a/src/libsystemd/sd-journal/journal-file.h b/src/libsystemd/sd-journal/journal-file.h
|
||||
index 1f3c80c912..0321da4a16 100644
|
||||
--- a/src/libsystemd/sd-journal/journal-file.h
|
||||
+++ b/src/libsystemd/sd-journal/journal-file.h
|
||||
@@ -305,10 +305,16 @@ bool journal_file_rotate_suggested(JournalFile *f, usec_t max_file_usec, int log
|
||||
int journal_file_map_data_hash_table(JournalFile *f);
|
||||
int journal_file_map_field_hash_table(JournalFile *f);
|
||||
|
||||
-static inline bool JOURNAL_FILE_COMPRESS(JournalFile *f) {
|
||||
+static inline Compression JOURNAL_FILE_COMPRESSION(JournalFile *f) {
|
||||
assert(f);
|
||||
- return JOURNAL_HEADER_COMPRESSED_XZ(f->header) || JOURNAL_HEADER_COMPRESSED_LZ4(f->header) ||
|
||||
- JOURNAL_HEADER_COMPRESSED_ZSTD(f->header);
|
||||
+
|
||||
+ if (JOURNAL_HEADER_COMPRESSED_XZ(f->header))
|
||||
+ return COMPRESSION_XZ;
|
||||
+ if (JOURNAL_HEADER_COMPRESSED_LZ4(f->header))
|
||||
+ return COMPRESSION_LZ4;
|
||||
+ if (JOURNAL_HEADER_COMPRESSED_ZSTD(f->header))
|
||||
+ return COMPRESSION_ZSTD;
|
||||
+ return COMPRESSION_NONE;
|
||||
}
|
||||
|
||||
uint64_t journal_file_hash_data(JournalFile *f, const void *data, size_t sz);
|
@ -0,0 +1,54 @@
|
||||
From 7c20d0bfec62de66e81f6b6e1c7ce9f3a3b3d5cf Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Tue, 4 Apr 2023 15:03:35 +0900
|
||||
Subject: [PATCH] test: add test case that journal file is created with the
|
||||
requested compression algorithm
|
||||
|
||||
(cherry picked from commit d23a1c52a93206b0dbabcb4336752ccb796c11c3)
|
||||
|
||||
Resolves: #2184929
|
||||
---
|
||||
test/units/testsuite-04.sh | 32 ++++++++++++++++++++++++++++++++
|
||||
1 file changed, 32 insertions(+)
|
||||
|
||||
diff --git a/test/units/testsuite-04.sh b/test/units/testsuite-04.sh
|
||||
index fdc3273fea..bb41045809 100755
|
||||
--- a/test/units/testsuite-04.sh
|
||||
+++ b/test/units/testsuite-04.sh
|
||||
@@ -179,4 +179,36 @@ sleep 3
|
||||
# https://github.com/systemd/systemd/issues/15528
|
||||
journalctl --follow --file=/var/log/journal/*/* | head -n1 || [[ $? -eq 1 ]]
|
||||
|
||||
+# https://bugzilla.redhat.com/show_bug.cgi?id=2183546
|
||||
+mkdir /run/systemd/system/systemd-journald.service.d
|
||||
+MID=$(cat /etc/machine-id)
|
||||
+for c in "NONE" "XZ" "LZ4" "ZSTD"; do
|
||||
+ cat >/run/systemd/system/systemd-journald.service.d/compress.conf <<EOF
|
||||
+[Service]
|
||||
+Environment=SYSTEMD_JOURNAL_COMPRESS=${c}
|
||||
+EOF
|
||||
+ systemctl daemon-reload
|
||||
+ systemctl restart systemd-journald.service
|
||||
+ journalctl --rotate
|
||||
+
|
||||
+ ID=$(systemd-id128 new)
|
||||
+ systemd-cat -t "$ID" /bin/bash -c "for ((i=0;i<100;i++)); do echo -n hoge with ${c}; done; echo"
|
||||
+ journalctl --sync
|
||||
+ timeout 10 bash -c "while ! SYSTEMD_LOG_LEVEL=debug journalctl --verify --quiet --file /var/log/journal/$MID/system.journal 2>&1 | grep -q -F 'compress=${c}'; do sleep .5; done"
|
||||
+
|
||||
+ # $SYSTEMD_JOURNAL_COMPRESS= also works for journal-remote
|
||||
+ if [[ -x /usr/lib/systemd/systemd-journal-remote ]]; then
|
||||
+ for cc in "NONE" "XZ" "LZ4" "ZSTD"; do
|
||||
+ rm -f /tmp/foo.journal
|
||||
+ SYSTEMD_JOURNAL_COMPRESS="${cc}" /usr/lib/systemd/systemd-journal-remote --split-mode=none -o /tmp/foo.journal --getter="journalctl -b -o export -t $ID"
|
||||
+ SYSTEMD_LOG_LEVEL=debug journalctl --verify --quiet --file /tmp/foo.journal 2>&1 | grep -q -F "compress=${cc}"
|
||||
+ journalctl -t "$ID" -o cat --file /tmp/foo.journal | grep -q -F "hoge with ${c}"
|
||||
+ done
|
||||
+ fi
|
||||
+done
|
||||
+rm /run/systemd/system/systemd-journald.service.d/compress.conf
|
||||
+systemctl daemon-reload
|
||||
+systemctl restart systemd-journald.service
|
||||
+journalctl --rotate
|
||||
+
|
||||
touch /testok
|
@ -0,0 +1,51 @@
|
||||
From 15d494b7ee019ab3e3a2a8e61c73ea8693ddb8ba Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Mon, 17 Apr 2023 14:51:19 +0200
|
||||
Subject: [PATCH] ci: workflow for gathering metadata for source-git automation
|
||||
|
||||
Workflow gathers metadata like pull request numbers and information about commits.
|
||||
This metadata is used for commit validation and other actions.
|
||||
This workflow also triggers for rest of the source-git automation workflows.
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2184929
|
||||
---
|
||||
.github/workflows/gather-metadata.yml | 28 +++++++++++++++++++++++++++
|
||||
1 file changed, 28 insertions(+)
|
||||
create mode 100644 .github/workflows/gather-metadata.yml
|
||||
|
||||
diff --git a/.github/workflows/gather-metadata.yml b/.github/workflows/gather-metadata.yml
|
||||
new file mode 100644
|
||||
index 0000000000..635708a71f
|
||||
--- /dev/null
|
||||
+++ b/.github/workflows/gather-metadata.yml
|
||||
@@ -0,0 +1,28 @@
|
||||
+name: Gather Pull Request Metadata
|
||||
+on:
|
||||
+ pull_request:
|
||||
+ types: [ opened, reopened, synchronize ]
|
||||
+ branches:
|
||||
+ - main
|
||||
+ - rhel-9.*.0
|
||||
+
|
||||
+permissions:
|
||||
+ contents: read
|
||||
+
|
||||
+jobs:
|
||||
+ gather-metadata:
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ steps:
|
||||
+ - name: Repository checkout
|
||||
+ uses: actions/checkout@v3
|
||||
+
|
||||
+ - id: Metadata
|
||||
+ name: Gather Pull Request Metadata
|
||||
+ uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1
|
||||
+
|
||||
+ - name: Upload artifact with gathered metadata
|
||||
+ uses: actions/upload-artifact@v3
|
||||
+ with:
|
||||
+ name: pr-metadata
|
||||
+ path: ${{ steps.Metadata.outputs.metadata-file }}
|
@ -0,0 +1,103 @@
|
||||
From 47c1a02ba0e669484e93dd78dd475592ecaa4cbd Mon Sep 17 00:00:00 2001
|
||||
From: Jan Macku <jamacku@redhat.com>
|
||||
Date: Mon, 17 Apr 2023 14:59:55 +0200
|
||||
Subject: [PATCH] ci: first part of the source-git automation - commit linter
|
||||
|
||||
Add a GitHub Workflow that is triggered on `workflow_run` events.
|
||||
It uses metadata provided by `redhat-plumbers-in-action/gather-pull-request-metadata`
|
||||
GitHub Action to get the PR number and the commit metadata.
|
||||
The commit metadata is then used to check if the commit message contains
|
||||
all required information (tracker and upstream reference). GitHub Action
|
||||
responsible for commit verification `redhat-plumbers-in-action/advanced-commit-linter`
|
||||
is configured via the `advanced-commit-linter.yml` file.
|
||||
|
||||
rhel-only
|
||||
|
||||
Related: #2184929
|
||||
---
|
||||
.github/advanced-commit-linter.yml | 23 +++++++++++
|
||||
.github/workflows/source-git-automation.yml | 45 +++++++++++++++++++++
|
||||
2 files changed, 68 insertions(+)
|
||||
create mode 100644 .github/advanced-commit-linter.yml
|
||||
create mode 100644 .github/workflows/source-git-automation.yml
|
||||
|
||||
diff --git a/.github/advanced-commit-linter.yml b/.github/advanced-commit-linter.yml
|
||||
new file mode 100644
|
||||
index 0000000000..491836abbb
|
||||
--- /dev/null
|
||||
+++ b/.github/advanced-commit-linter.yml
|
||||
@@ -0,0 +1,23 @@
|
||||
+policy:
|
||||
+ cherry-pick:
|
||||
+ upstream:
|
||||
+ - github: systemd/systemd
|
||||
+ - github: systemd/systemd-stable
|
||||
+ exception:
|
||||
+ note:
|
||||
+ - rhel-only
|
||||
+ tracker:
|
||||
+ - keyword:
|
||||
+ - 'Resolves: #?'
|
||||
+ - 'Related: #?'
|
||||
+ - 'Reverts: #?'
|
||||
+ issue-format:
|
||||
+ - '\d+$'
|
||||
+ url: 'https://bugzilla.redhat.com/show_bug.cgi?id='
|
||||
+ - keyword:
|
||||
+ - 'Resolves: '
|
||||
+ - 'Related: '
|
||||
+ - 'Reverts: '
|
||||
+ issue-format:
|
||||
+ - 'RHEL-\d+$'
|
||||
+ url: 'https://issues.redhat.com/browse/'
|
||||
diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml
|
||||
new file mode 100644
|
||||
index 0000000000..140f21b116
|
||||
--- /dev/null
|
||||
+++ b/.github/workflows/source-git-automation.yml
|
||||
@@ -0,0 +1,45 @@
|
||||
+name: Source git Automation
|
||||
+on:
|
||||
+ workflow_run:
|
||||
+ workflows: [ Gather Pull Request Metadata ]
|
||||
+ types:
|
||||
+ - completed
|
||||
+
|
||||
+permissions:
|
||||
+ contents: read
|
||||
+
|
||||
+jobs:
|
||||
+ download-metadata:
|
||||
+ if: >
|
||||
+ github.event.workflow_run.event == 'pull_request' &&
|
||||
+ github.event.workflow_run.conclusion == 'success'
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ outputs:
|
||||
+ pr-metadata: ${{ steps.Artifact.outputs.pr-metadata-json }}
|
||||
+
|
||||
+ steps:
|
||||
+ - id: Artifact
|
||||
+ name: Download Artifact
|
||||
+ uses: redhat-plumbers-in-action/download-artifact@v1
|
||||
+ with:
|
||||
+ name: pr-metadata
|
||||
+
|
||||
+ commit-linter:
|
||||
+ needs: [ download-metadata ]
|
||||
+ runs-on: ubuntu-latest
|
||||
+
|
||||
+ outputs:
|
||||
+ validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }}
|
||||
+
|
||||
+ permissions:
|
||||
+ statuses: write
|
||||
+ pull-requests: write
|
||||
+
|
||||
+ steps:
|
||||
+ - id: commit-linter
|
||||
+ name: Lint Commits
|
||||
+ uses: redhat-plumbers-in-action/advanced-commit-linter@v1
|
||||
+ with:
|
||||
+ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
|
||||
+ token: ${{ secrets.GITHUB_TOKEN }}
|
Loading…
Reference in new issue