From 680ddc7e104e5f40d8e6be5054544918d881acae Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Tue, 2 Nov 2021 23:12:27 +0100 Subject: [PATCH 1/2] Move clang-format, safe-wrappers, release notes check in new job Benefits: - Faster feedback in case of error - More checks run in parallel - Removes stuff from Dockerfiles - Uses newest available clang-format (in ubuntu repos) --- .github/workflows/main.yml | 22 ++++++++++++++-------- travis/check-formatting.sh | 6 ------ travis/travis-base-386.Dockerfile | 3 +-- travis/travis-base-ubuntu-386.Dockerfile | 3 +-- travis/travis-base-ubuntu.Dockerfile | 3 +-- travis/travis-base.Dockerfile | 3 +-- 6 files changed, 18 insertions(+), 22 deletions(-) delete mode 100755 travis/check-formatting.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e106776e0..0bba6a044 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,8 +25,6 @@ jobs: steps: - uses: actions/checkout@v2 - run: git fetch --prune --unshallow - - name: check & print release notes - run: ./release-notes/generator.pl - name: construct container name run: | echo "BASENAME=i3wm/travis-base:$(date +'%Y-%m')-$(./travis/ha.sh travis/travis-base.Dockerfile)" >> $GITHUB_ENV @@ -47,12 +45,6 @@ jobs: echo "::group::Ubuntu i386" ./travis/skip-pkg.sh || docker pull ${{ env.BASENAME_UBUNTU_386 }} || ./travis/docker-build-and-push.sh ${{ env.BASENAME_UBUNTU_386 }} travis/travis-base-ubuntu-386.Dockerfile echo "::endgroup::" - - name: verify safe wrapper functions are used - run: | - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 ${{ env.BASENAME }} ./travis/check-safe-wrappers.sh - - name: verify code formatting - run: | - docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 ${{ env.BASENAME }} ./travis/check-formatting.sh - name: build i3 run: | docker run -v $PWD:/usr/src/i3/ -w /usr/src/i3 -e CC ${{ env.BASENAME }} /bin/sh -c 'rm -rf build; mkdir -p build && cd build && CFLAGS="-Wformat -Wformat-security -Wextra -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Werror -fno-common" meson .. -Ddocs=true -Dmans=true -Db_sanitize=address && ninja -v' @@ -94,3 +86,17 @@ jobs: - name: push docs to GitHub pages run: | ./travis/skip-pkg.sh || travis/deploy-github-pages.sh + formatting: + name: Check formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: check & print release notes + run: ./release-notes/generator.pl + - name: Install dependencies + run: | + sudo apt-get install -y clang-format-10 + - name: Check formatting + run: clang-format-10 --dry-run --Werror $(git ls-files '*.c' '*.h') + - name: Verify safe wrapper functions are used + run: ./travis/check-safe-wrappers.sh diff --git a/travis/check-formatting.sh b/travis/check-formatting.sh deleted file mode 100755 index 3424513f9..000000000 --- a/travis/check-formatting.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -set -e -set -x - -clang-format-9 -i $(find . -name "*.[ch]" | tr '\n' ' ') && git diff --exit-code || (echo 'Code was not formatted using clang-format!'; false) diff --git a/travis/travis-base-386.Dockerfile b/travis/travis-base-386.Dockerfile index fc0350344..fab1a48f7 100644 --- a/travis/travis-base-386.Dockerfile +++ b/travis/travis-base-386.Dockerfile @@ -13,12 +13,11 @@ RUN echo 'APT::Acquire::Retries "5";' > /etc/apt/apt.conf.d/80retry # (3608 kB/s)). Hence, let’s stick with httpredir.debian.org (default) for now. # Install mk-build-deps (for installing the i3 build dependencies), -# clang and clang-format-9 (for checking formatting and building with clang), # lintian (for checking spelling errors), RUN linux32 apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ dpkg-dev devscripts git equivs \ - build-essential clang clang-format-9 \ + build-essential clang \ lintian && \ rm -rf /var/lib/apt/lists/* diff --git a/travis/travis-base-ubuntu-386.Dockerfile b/travis/travis-base-ubuntu-386.Dockerfile index 747330aa3..a66d58a2c 100644 --- a/travis/travis-base-ubuntu-386.Dockerfile +++ b/travis/travis-base-ubuntu-386.Dockerfile @@ -13,12 +13,11 @@ RUN echo 'APT::Acquire::Retries "5";' > /etc/apt/apt.conf.d/80retry # (3608 kB/s)). Hence, let’s stick with httpredir.debian.org (default) for now. # Install mk-build-deps (for installing the i3 build dependencies), -# clang and clang-format-9 (for checking formatting and building with clang), # lintian (for checking spelling errors), RUN linux32 apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ dpkg-dev devscripts git equivs \ - build-essential clang clang-format-9 \ + build-essential clang \ lintian && \ rm -rf /var/lib/apt/lists/* diff --git a/travis/travis-base-ubuntu.Dockerfile b/travis/travis-base-ubuntu.Dockerfile index 8a728af32..9ee9d3554 100644 --- a/travis/travis-base-ubuntu.Dockerfile +++ b/travis/travis-base-ubuntu.Dockerfile @@ -13,13 +13,12 @@ RUN echo 'APT::Acquire::Retries "5";' > /etc/apt/apt.conf.d/80retry # (3608 kB/s)). Hence, let’s stick with httpredir.debian.org (default) for now. # Install mk-build-deps (for installing the i3 build dependencies), -# clang and clang-format-9 (for checking formatting and building with clang), # lintian (for checking spelling errors), # test suite dependencies (for running tests) RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ dpkg-dev devscripts git equivs \ - build-essential clang clang-format-9 \ + build-essential clang \ lintian && \ rm -rf /var/lib/apt/lists/* diff --git a/travis/travis-base.Dockerfile b/travis/travis-base.Dockerfile index e5552c144..da5531ffa 100644 --- a/travis/travis-base.Dockerfile +++ b/travis/travis-base.Dockerfile @@ -11,13 +11,12 @@ RUN echo 'APT::Acquire::Retries "5";' > /etc/apt/apt.conf.d/80retry # (3608 kB/s)). Hence, let’s stick with httpredir.debian.org (default) for now. # Install mk-build-deps (for installing the i3 build dependencies), -# clang and clang-format-9 (for checking formatting and building with clang), # lintian (for checking spelling errors), # test suite dependencies (for running tests) RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ dpkg-dev devscripts git equivs \ - build-essential clang clang-format-9 \ + build-essential clang \ lintian \ libmodule-install-perl libanyevent-perl libextutils-pkgconfig-perl xcb-proto cpanminus xvfb xserver-xephyr xauth libinline-perl libinline-c-perl libxml-simple-perl libmouse-perl libmousex-nativetraits-perl libextutils-depends-perl perl libtest-deep-perl libtest-exception-perl libxml-parser-perl libtest-simple-perl libtest-fatal-perl libdata-dump-perl libtest-differences-perl libxml-tokeparser-perl libipc-run-perl libxcb-xtest0-dev libx11-xcb-perl libjson-xs-perl x11-xserver-utils && \ rm -rf /var/lib/apt/lists/* From 7f3316269d1e8e4992d17f1ae35bd54587fb2b0f Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sat, 6 Nov 2021 14:13:18 +0100 Subject: [PATCH 2/2] Release notes script fixes (#4652) * release-notes: Sort filenames * release-notes: Fix print-urls --- release-notes/generator.pl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/release-notes/generator.pl b/release-notes/generator.pl index 6996d7a9f..d77eb0982 100755 --- a/release-notes/generator.pl +++ b/release-notes/generator.pl @@ -29,10 +29,17 @@ my $print_urls = 0; my $result = GetOptions('print-urls' => \$print_urls); +sub get_number { + my $s = shift; + return $1 if $s =~ m/^(\d+)/; + return -1; +} + sub read_changefiles { my $dirpath = shift; opendir my $dir, $dirpath or die "Cannot open directory $dirpath: $!"; - my @files = readdir $dir; + my @files = sort { get_number($a) <=> get_number($b) } readdir $dir; + closedir $dir; my $s = ''; @@ -41,7 +48,7 @@ sub read_changefiles { next if $filename eq '..'; next if $filename eq '0-example'; - die "Filename $filename should start with a number (e.g. the pull request number)" unless ($filename =~ /^\d+/); + die "Filename $filename should start with a number (e.g. the pull request number)" unless get_number($filename) > 0; $filename = $dirpath . '/' . $filename; open my $in, '<', $filename or die "can't open $filename: $!"; @@ -51,14 +58,14 @@ sub read_changefiles { my $content = trim(join("\n ", map { trim($_) } @lines)); die "$filename can't be empty" unless length($content) > 0; - my $commit = `git log --diff-filter=A --pretty=format:"%H" $filename`; - $commit = trim($commit) if defined($commit); - die "$filename: git log failed to find commit" if ($?) || (length($commit) == 0); - my $url = ''; if ($print_urls) { + my $commit = `git log --diff-filter=A --pretty=format:"%H" $filename`; + $commit = trim($commit) if defined($commit); + die "$filename: git log failed to find commit" if ($?) || (length($commit) == 0); + my $pr = find_pr($commit); - my $url = 'https://github.com/i3/i3/commit/' . $commit; + $url = 'https://github.com/i3/i3/commit/' . $commit; $url = 'https://github.com/i3/i3/pull/' . $pr if defined($pr); $url = $url . "\n"; }