From 5b847561370fe768775390afc0c82cb7302f3f80 Mon Sep 17 00:00:00 2001 From: Otto Richter Date: Fri, 27 Sep 2024 20:44:22 +0200 Subject: [PATCH 1/3] Split env preparation boilerplate --- .../workflows/composite/setup-env/action.yaml | 11 ++++ .forgejo/workflows/testing.yml | 51 +++---------------- 2 files changed, 18 insertions(+), 44 deletions(-) create mode 100644 .forgejo/workflows/composite/setup-env/action.yaml diff --git a/.forgejo/workflows/composite/setup-env/action.yaml b/.forgejo/workflows/composite/setup-env/action.yaml new file mode 100644 index 0000000000..30e78dbb71 --- /dev/null +++ b/.forgejo/workflows/composite/setup-env/action.yaml @@ -0,0 +1,11 @@ +runs: + using: "composite" + steps: + - uses: https://code.forgejo.org/actions/setup-go@v4 + with: + go-version-file: "go.mod" + - name: setup user and permissions + run: | + git config --add safe.directory '*' + adduser --quiet --comment forgejo --disabled-password forgejo + chown -R forgejo:forgejo . diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 725cd242ee..d5c7b86abb 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -20,9 +20,7 @@ jobs: ${{ toJSON(github) }} EOF - uses: https://code.forgejo.org/actions/checkout@v3 - - uses: https://code.forgejo.org/actions/setup-go@v4 - with: - go-version-file: "go.mod" + - uses: ./.forgejo/workflows/composite/setup-env - run: make deps-backend deps-tools - run: make --always-make -j$(nproc) lint-backend tidy-check swagger-check fmt-check swagger-validate # ensure the "go-licenses" make target runs - run: | @@ -67,13 +65,7 @@ jobs: MINIO_ROOT_PASSWORD: 12345678 steps: - uses: https://code.forgejo.org/actions/checkout@v3 - - uses: https://code.forgejo.org/actions/setup-go@v4 - with: - go-version-file: "go.mod" - - run: | - git config --add safe.directory '*' - adduser --quiet --comment forgejo --disabled-password forgejo - chown -R forgejo:forgejo . + - uses: ./.forgejo/workflows/composite/setup-env - name: install git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -132,13 +124,7 @@ jobs: options: ${{ matrix.cacher.options }} steps: - uses: https://code.forgejo.org/actions/checkout@v3 - - uses: https://code.forgejo.org/actions/setup-go@v4 - with: - go-version-file: "go.mod" - - run: | - git config --add safe.directory '*' - adduser --quiet --comment forgejo --disabled-password forgejo - chown -R forgejo:forgejo . + - uses: ./.forgejo/workflows/composite/setup-env - name: install git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -184,9 +170,7 @@ jobs: MYSQL_EXTRA_FLAGS: --innodb-adaptive-flushing=OFF --innodb-buffer-pool-size=4G --innodb-log-buffer-size=128M --innodb-flush-log-at-trx-commit=0 --innodb-flush-log-at-timeout=30 --innodb-flush-method=nosync --innodb-fsync-threshold=1000000000 steps: - uses: https://code.forgejo.org/actions/checkout@v3 - - uses: https://code.forgejo.org/actions/setup-go@v4 - with: - go-version-file: "go.mod" + - uses: ./.forgejo/workflows/composite/setup-env - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -195,11 +179,6 @@ jobs: apt-get install --no-install-recommends -qq -y git git-lfs rm /etc/apt/sources.list.d/testing.list apt-get update -qq - - name: setup user and permissions - run: | - git config --add safe.directory '*' - adduser --quiet --comment forgejo --disabled-password forgejo - chown -R forgejo:forgejo . - run: | su forgejo -c 'make deps-backend' - uses: actions/cache/restore@v4 @@ -238,9 +217,7 @@ jobs: POSTGRES_PASSWORD: postgres steps: - uses: https://code.forgejo.org/actions/checkout@v3 - - uses: https://code.forgejo.org/actions/setup-go@v4 - with: - go-version-file: "go.mod" + - uses: ./.forgejo/workflows/composite/setup-env - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -249,11 +226,6 @@ jobs: apt-get install --no-install-recommends -qq -y git git-lfs rm /etc/apt/sources.list.d/testing.list apt-get update -qq - - name: setup user and permissions - run: | - git config --add safe.directory '*' - adduser --quiet --comment forgejo --disabled-password forgejo - chown -R forgejo:forgejo . - run: | su forgejo -c 'make deps-backend' - uses: actions/cache/restore@v4 @@ -281,9 +253,7 @@ jobs: image: 'code.forgejo.org/oci/node:20-bookworm' steps: - uses: https://code.forgejo.org/actions/checkout@v3 - - uses: https://code.forgejo.org/actions/setup-go@v4 - with: - go-version-file: "go.mod" + - uses: ./.forgejo/workflows/composite/setup-env - name: install dependencies & git >= 2.42 run: | export DEBIAN_FRONTEND=noninteractive @@ -292,11 +262,6 @@ jobs: apt-get install --no-install-recommends -qq -y git git-lfs rm /etc/apt/sources.list.d/testing.list apt-get update -qq - - name: setup user and permissions - run: | - git config --add safe.directory '*' - adduser --quiet --comment forgejo --disabled-password forgejo - chown -R forgejo:forgejo . - run: | su forgejo -c 'make deps-backend' - uses: actions/cache/restore@v4 @@ -330,8 +295,6 @@ jobs: image: 'code.forgejo.org/oci/node:20-bookworm' steps: - uses: https://code.forgejo.org/actions/checkout@v3 - - uses: https://code.forgejo.org/actions/setup-go@v4 - with: - go-version-file: "go.mod" + - uses: ./.forgejo/workflows/composite/setup-env - run: make deps-backend deps-tools - run: make security-check From c0b17a06ef53d122644304dd8a85a01a3c842ade Mon Sep 17 00:00:00 2001 From: Otto Richter Date: Fri, 27 Sep 2024 20:47:09 +0200 Subject: [PATCH 2/3] Split backend building boilerplate --- .../composite/build-backend/action.yaml | 15 ++++ .forgejo/workflows/testing.yml | 78 ++----------------- 2 files changed, 23 insertions(+), 70 deletions(-) create mode 100644 .forgejo/workflows/composite/build-backend/action.yaml diff --git a/.forgejo/workflows/composite/build-backend/action.yaml b/.forgejo/workflows/composite/build-backend/action.yaml new file mode 100644 index 0000000000..193ff911e1 --- /dev/null +++ b/.forgejo/workflows/composite/build-backend/action.yaml @@ -0,0 +1,15 @@ +runs: + using: "composite" + steps: + - run: | + su forgejo -c 'make deps-backend' + - uses: actions/cache@v4 + id: cache-backend + with: + path: '/workspace/forgejo/forgejo/gitea' + key: backend-build-${{ github.sha }} + - if: steps.cache-backend.outputs.cache-hit != 'true' + run: | + su forgejo -c 'make backend' + env: + TAGS: bindata diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index d5c7b86abb..5f7a1e351a 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -21,16 +21,9 @@ jobs: EOF - uses: https://code.forgejo.org/actions/checkout@v3 - uses: ./.forgejo/workflows/composite/setup-env - - run: make deps-backend deps-tools - - run: make --always-make -j$(nproc) lint-backend tidy-check swagger-check fmt-check swagger-validate # ensure the "go-licenses" make target runs - - run: | - make backend - env: - TAGS: bindata - - uses: actions/cache@v4 - with: - path: '/workspace/forgejo/forgejo/gitea' - key: backend-build-${{ github.sha }} + - run: su forgejo -c 'make deps-backend deps-tools' + - run: su forgejo -c 'make --always-make -j$(nproc) lint-backend tidy-check swagger-check fmt-check swagger-validate' # ensure the "go-licenses" make target runs + - uses: ./.forgejo/workflows/composite/build-backend frontend-checks: if: ${{ !startsWith(vars.ROLE, 'forgejo-') }} runs-on: docker @@ -78,18 +71,7 @@ jobs: run: | apt-get -q install -qq -y jq ./release-notes-assistant.sh test_main - - run: | - su forgejo -c 'make deps-backend' - - uses: actions/cache/restore@v4 - id: cache-backend - with: - path: '/workspace/forgejo/forgejo/gitea' - key: backend-build-${{ github.sha }} - - if: steps.cache-backend.outputs.cache-hit != 'true' - run: | - su forgejo -c 'make backend' - env: - TAGS: bindata + - uses: ./.forgejo/workflows/composite/build-backend - run: | su forgejo -c 'make test-backend test-check' timeout-minutes: 50 @@ -133,18 +115,7 @@ jobs: apt-get -q install -qq -y git rm /etc/apt/sources.list.d/testing.list apt-get update -qq - - run: | - su forgejo -c 'make deps-backend' - - uses: actions/cache/restore@v4 - id: cache-backend - with: - path: '/workspace/forgejo/forgejo/gitea' - key: backend-build-${{ github.sha }} - - if: steps.cache-backend.outputs.cache-hit != 'true' - run: | - su forgejo -c 'make backend' - env: - TAGS: bindata + - uses: ./.forgejo/workflows/composite/build-backend - run: | su forgejo -c 'make test-remote-cacher test-check' timeout-minutes: 50 @@ -179,18 +150,7 @@ jobs: apt-get install --no-install-recommends -qq -y git git-lfs rm /etc/apt/sources.list.d/testing.list apt-get update -qq - - run: | - su forgejo -c 'make deps-backend' - - uses: actions/cache/restore@v4 - id: cache-backend - with: - path: '/workspace/forgejo/forgejo/gitea' - key: backend-build-${{ github.sha }} - - if: steps.cache-backend.outputs.cache-hit != 'true' - run: | - su forgejo -c 'make backend' - env: - TAGS: bindata + - uses: ./.forgejo/workflows/composite/build-backend - run: | su forgejo -c 'make test-mysql-migration test-mysql' timeout-minutes: 50 @@ -226,18 +186,7 @@ jobs: apt-get install --no-install-recommends -qq -y git git-lfs rm /etc/apt/sources.list.d/testing.list apt-get update -qq - - run: | - su forgejo -c 'make deps-backend' - - uses: actions/cache/restore@v4 - id: cache-backend - with: - path: '/workspace/forgejo/forgejo/gitea' - key: backend-build-${{ github.sha }} - - if: steps.cache-backend.outputs.cache-hit != 'true' - run: | - su forgejo -c 'make backend' - env: - TAGS: bindata + - uses: ./.forgejo/workflows/composite/build-backend - run: | su forgejo -c 'make test-pgsql-migration test-pgsql' timeout-minutes: 50 @@ -262,18 +211,7 @@ jobs: apt-get install --no-install-recommends -qq -y git git-lfs rm /etc/apt/sources.list.d/testing.list apt-get update -qq - - run: | - su forgejo -c 'make deps-backend' - - uses: actions/cache/restore@v4 - id: cache-backend - with: - path: '/workspace/forgejo/forgejo/gitea' - key: backend-build-${{ github.sha }} - - if: steps.cache-backend.outputs.cache-hit != 'true' - run: | - su forgejo -c 'make backend' - env: - TAGS: bindata sqlite sqlite_unlock_notify + - uses: ./.forgejo/workflows/composite/build-backend - run: | su forgejo -c 'make test-sqlite-migration test-sqlite' timeout-minutes: 50 From 1fa09d16210f825ea5aee5d87294c957d405a108 Mon Sep 17 00:00:00 2001 From: Otto Richter Date: Sat, 28 Sep 2024 03:39:19 +0200 Subject: [PATCH 3/3] Split Git package installation --- .../composite/apt-install-from/action.yaml | 29 +++++++++++ .forgejo/workflows/testing.yml | 50 ++++++------------- 2 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 .forgejo/workflows/composite/apt-install-from/action.yaml diff --git a/.forgejo/workflows/composite/apt-install-from/action.yaml b/.forgejo/workflows/composite/apt-install-from/action.yaml new file mode 100644 index 0000000000..615e7cb184 --- /dev/null +++ b/.forgejo/workflows/composite/apt-install-from/action.yaml @@ -0,0 +1,29 @@ +inputs: + packages: + description: 'Packages to install' + required: true + release: + description: 'Release to install from' + default: testing + +runs: + using: "composite" + steps: + - name: setup apt package source + run: | + export DEBIAN_FRONTEND=noninteractive + echo "deb http://deb.debian.org/debian/ ${RELEASE} main" > "/etc/apt/sources.list.d/${RELEASE}.list" + env: + RELEASE: ${{inputs.release}} + - name: install packages + run: | + apt-get update -qq + apt-get -q install -qq -y ${PACKAGES} + env: + PACKAGES: ${{inputs.packages}} + - name: remove temporary package list to prevent using it in other steps + run: | + rm "/etc/apt/sources.list.d/${RELEASE}.list" + apt-get update -qq + env: + RELEASE: ${{inputs.release}} diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 5f7a1e351a..8c1e6d06f8 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -60,13 +60,9 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: ./.forgejo/workflows/composite/setup-env - name: install git >= 2.42 - run: | - export DEBIAN_FRONTEND=noninteractive - echo deb http://deb.debian.org/debian/ testing main > /etc/apt/sources.list.d/testing.list - apt-get update -qq - apt-get -q install -qq -y git - rm /etc/apt/sources.list.d/testing.list - apt-get update -qq + uses: ./.forgejo/workflows/composite/apt-install-from + with: + packages: git - name: test release-notes-assistant.sh run: | apt-get -q install -qq -y jq @@ -108,13 +104,9 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: ./.forgejo/workflows/composite/setup-env - name: install git >= 2.42 - run: | - export DEBIAN_FRONTEND=noninteractive - echo deb http://deb.debian.org/debian/ testing main > /etc/apt/sources.list.d/testing.list - apt-get update -qq - apt-get -q install -qq -y git - rm /etc/apt/sources.list.d/testing.list - apt-get update -qq + uses: ./.forgejo/workflows/composite/apt-install-from + with: + packages: git - uses: ./.forgejo/workflows/composite/build-backend - run: | su forgejo -c 'make test-remote-cacher test-check' @@ -143,13 +135,9 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: ./.forgejo/workflows/composite/setup-env - name: install dependencies & git >= 2.42 - run: | - export DEBIAN_FRONTEND=noninteractive - echo deb http://deb.debian.org/debian/ testing main > /etc/apt/sources.list.d/testing.list - apt-get update -qq - apt-get install --no-install-recommends -qq -y git git-lfs - rm /etc/apt/sources.list.d/testing.list - apt-get update -qq + uses: ./.forgejo/workflows/composite/apt-install-from + with: + packages: git git-lfs - uses: ./.forgejo/workflows/composite/build-backend - run: | su forgejo -c 'make test-mysql-migration test-mysql' @@ -179,13 +167,9 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: ./.forgejo/workflows/composite/setup-env - name: install dependencies & git >= 2.42 - run: | - export DEBIAN_FRONTEND=noninteractive - echo deb http://deb.debian.org/debian/ testing main > /etc/apt/sources.list.d/testing.list - apt-get update -qq - apt-get install --no-install-recommends -qq -y git git-lfs - rm /etc/apt/sources.list.d/testing.list - apt-get update -qq + uses: ./.forgejo/workflows/composite/apt-install-from + with: + packages: git git-lfs - uses: ./.forgejo/workflows/composite/build-backend - run: | su forgejo -c 'make test-pgsql-migration test-pgsql' @@ -204,13 +188,9 @@ jobs: - uses: https://code.forgejo.org/actions/checkout@v3 - uses: ./.forgejo/workflows/composite/setup-env - name: install dependencies & git >= 2.42 - run: | - export DEBIAN_FRONTEND=noninteractive - echo deb http://deb.debian.org/debian/ testing main > /etc/apt/sources.list.d/testing.list - apt-get update -qq - apt-get install --no-install-recommends -qq -y git git-lfs - rm /etc/apt/sources.list.d/testing.list - apt-get update -qq + uses: ./.forgejo/workflows/composite/apt-install-from + with: + packages: git git-lfs - uses: ./.forgejo/workflows/composite/build-backend - run: | su forgejo -c 'make test-sqlite-migration test-sqlite'