Skip to content

Commit

Permalink
github: fix + enable cron workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Dec 29, 2024
1 parent 936c178 commit abc1586
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 100 deletions.
62 changes: 62 additions & 0 deletions .github/actions/setup-ninja/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Setup ninja'
description: 'Download ninja and add it to the PATH environment variable'
inputs:
version:
description: 'Ninja version'
default: '1.12.1'
runs:
using: 'composite'
steps:
- name: 'Calculate variables'
id: calc
shell: sh
run: |
case "${{ runner.os }}-${{ runner.arch }}" in
"Linux-X86" | "Linux-X64")
archive="ninja-linux.zip"
;;
"Linux-ARM64")
archive="ninja-linux-aarch64.zip"
;;
"macOS-X86" | "macOS-X64" | "macOS-ARM64")
archive="ninja-mac.zip"
;;
"Windows-X86" | "Windows-X64")
archive="ninja-win.zip"
;;
"Windows-ARM64")
archive="ninja-winarm64.zip"
;;
*)
echo "Unsupported ${{ runner.os }}-${{ runner.arch }}"
exit 1;
;;
esac
echo "archive=${archive}" >> ${GITHUB_OUTPUT}
echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT}
- name: 'Restore cached ${{ steps.calc.outputs.archive }}'
id: cache-restore
uses: actions/cache/restore@v4
with:
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
- name: 'Download ninja ${{ inputs.version }} for ${{ runner.os }} (${{ runner.arch }})'
if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
shell: pwsh
run: |
Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v${{ inputs.version }}/${{ steps.calc.outputs.archive }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
- name: 'Cache ${{ steps.calc.outputs.archive }}'
if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }}
uses: actions/cache/save@v4
with:
path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}'
key: ${{ steps.calc.outputs.cache-key }}
- name: 'Extract ninja'
shell: pwsh
run: |
7z "-o${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" x "${{ runner.temp }}/${{ steps.calc.outputs.archive }}"
- name: 'Set output variables'
id: final
shell: pwsh
run: |
echo "${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" >> $env:GITHUB_PATH
86 changes: 86 additions & 0 deletions .github/scripts/mail-for-all-new-open-prs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import logging
import os
import re
import smtplib
import ssl

import github

logging.basicConfig(format='[%(asctime)s] %(message)s')
logging.root.setLevel(logging.INFO)

mailinglist_message = "The [mpg123-devel mailing list](https://sourceforge.net/p/mpg123/mailman/mpg123-devel/) has been notified of the existence of this pr."
mailinglist_label = "mailing-list-notified"

g = github.Github(os.environ["GITHUB_TOKEN"])
user_me = g.get_user()
repo = g.get_repo(os.environ["GITHUB_REPOSITORY"])

for pr in repo.get_pulls(state="open"):
logging.info("Checking PR #%d", pr.number)
already_handled = False
for label in pr.get_labels():
if label.name == mailinglist_label:
already_handled = True
if already_handled:
continue

logging.info("PR #%d was NOT handled already", pr.number)

mail_body = f"""\
A pull request by {pr.user.login} was opened at {pr.created_at}.
Please visit {pr.html_url} to give feedback and review the code.
---
{pr.body}
---
patch details:
- url: {pr.html_url}
- patch: {pr.html_url}.patch
url details:
- user name: {pr.user.login}
- user url: {pr.user.html_url}
"""
logging.info("mail body: %s", mail_body)

mail_title = "Opened GH-#{}: {} [{}]".format(pr.number, pr.title, pr.user.login)

logging.info("mail title: %s", mail_title)
logging.info("mail body: %s", mail_body)

mail_message = f"""\
MIME-Version: 1.0
Content-type: text/plain; charset=utf-8
Subject: {mail_title}
{mail_body}
"""

sender_email = "{} <{}>".format("{} (via github PR)".format(pr.user.login), os.environ["MAIL_SENDER"])
receiver_email = os.environ["MAIL_RECEIVER"].split(";")

logging.info("mail from: %s", re.sub("[a-z0-9]", "x", sender_email, flags=re.I))
logging.info("receiver to: %s", receiver_email)

port = 465
server = os.environ["MAIL_SERVER"]
login = os.environ["MAIL_LOGIN"]
password = os.environ["MAIL_PASSWORD"]

context = ssl.create_default_context()

with smtplib.SMTP_SSL(server, port, context=context) as server:
server.login(login, password)
server.sendmail(sender_email, receiver_email, mail_message)

logging.info("Creating comment at PR#%d", pr.number)
pr.add_to_labels(mailinglist_label)
comment = pr.create_issue_comment(mailinglist_message)
logging.info("Visit comment at %s", comment.html_url)

logging.info("mail sent")
30 changes: 0 additions & 30 deletions .github/workflows/CMake-MSVC-noyasm.yml

This file was deleted.

22 changes: 13 additions & 9 deletions .github/workflows/CMake-MSVC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:
steps:
- name: Restore yasm
id: restore-yasm
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: |
${{ github.workspace }}/yasm
key: yasm
- name: Download yasm sources
if: ${{ !steps.restore-yasm.outputs.cache-hit }}
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: yasm/yasm
path: yasm-src
Expand All @@ -24,9 +24,9 @@ jobs:
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Install ninja
- name: Setup ninja
if: ${{ !steps.restore-yasm.outputs.cache-hit }}
uses: turtlesec-no/get-ninja@main
uses: ./.github/actions/setup-ninja
- name: Build and install yasm
if: ${{ !steps.restore-yasm.outputs.cache-hit }}
run: |
Expand Down Expand Up @@ -55,24 +55,28 @@ jobs:
os: [windows-2022, windows-2019]
arch: [x86, x64, amd64_arm, amd64_arm64]
shared: [ON, OFF]
yasm: [true, false]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Restore yasm
uses: actions/cache/restore@v3
if: ${{ matrix.yasm }}
uses: actions/cache/restore@v4
with:
path: |
${{ github.workspace }}/yasm
key: yasm
- name: Add yasm to PATH
if: ${{ matrix.yasm }}
run: echo "${{ github.workspace }}/yasm/bin" >> %GITHUB_PATH%"
- name: Setup vcvars
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Install ninja
uses: turtlesec-no/get-ninja@main
sdK: ${{ (matrix.arch == 'amd64_arm' && '10.0.22621.0') || '' }}
- name: Setup ninja
uses: ./.github/actions/setup-ninja
- name: CMake (configure)
run: cmake -S ports/cmake -B build -GNinja -DYASM_ASSEMBLER=${{ github.workspace }}/yasm/bin/vsyasm.exe -DBUILD_SHARED_LIBS=${{ matrix.shared }}
run: cmake -S ports/cmake -B build -GNinja ${{ (matrix.yasm && format('-DYASM_ASSEMBLER={0}/yasm/bin/vsyasm.exe', github.workspace)) || '' }} -DBUILD_SHARED_LIBS=${{ matrix.shared }}
- name: CMake (Build)
run: cmake --build build --verbose
66 changes: 33 additions & 33 deletions .github/workflows/MSYS2.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
name: MSYS2

on: push

jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
matrix:
include:
- { sys: MINGW32, rep: mingw32, env: i686, mpg123build: x86 }
- { sys: MINGW64, rep: mingw64, env: x86_64, mpg123build: x86_64 }
steps:
- uses: actions/checkout@v3
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
update: true
install: msys/base-devel msys/autoconf msys/autoconf-archive msys/automake msys/ccache msys/doxygen msys/libtool msys/git msys/zip ${{matrix.rep}}/mingw-w64-${{matrix.env}}-toolchain ${{matrix.rep}}/mingw-w64-${{matrix.env}}-yasm
- name: setup parallel make
run: echo MAKEFLAGS=-j${NUMBER_OF_PROCESSORS} >> $GITHUB_ENV
- name: prepare Autotools
run: autoreconf -iv
- name: build
run: ./windows-builds.sh ${{matrix.mpg123build}}
- name: publish artifacts
uses: actions/upload-artifact@v3
with:
name: ${{matrix.mpg123build}}
path: releases/*.zip
name: MSYS2

on: push

jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
matrix:
include:
- { sys: MINGW32, rep: mingw32, env: i686, mpg123build: x86 }
- { sys: MINGW64, rep: mingw64, env: x86_64, mpg123build: x86_64 }
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
update: true
install: msys/base-devel msys/autoconf msys/autoconf-archive msys/automake msys/ccache msys/doxygen msys/libtool msys/git msys/zip ${{matrix.rep}}/mingw-w64-${{matrix.env}}-toolchain ${{matrix.rep}}/mingw-w64-${{matrix.env}}-yasm
- name: setup parallel make
run: echo MAKEFLAGS=-j${NUMBER_OF_PROCESSORS} >> $GITHUB_ENV
- name: prepare Autotools
run: autoreconf -iv
- name: build
run: ./windows-builds.sh ${{matrix.mpg123build}}
- name: publish artifacts
uses: actions/upload-artifact@v4
with:
name: ${{matrix.mpg123build}}
path: releases/*.zip
52 changes: 26 additions & 26 deletions .github/workflows/Ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: Ubuntu

on: push

jobs:
build:
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: install updates
run: sudo apt-get update && sudo apt-get dist-upgrade
- name: install build system
run: sudo apt-get install -y autoconf autoconf-archive automake pkg-config libtool libtool-bin libltdl-dev doxygen gcc yasm
- name: install dependencies
run: sudo apt-get install -y libasound2-dev libaudio-dev libjack-jackd2-dev libopenal-dev libpulse-dev libsdl1.2-dev libsdl2-dev libsndio-dev portaudio19-dev
- name: setup parallel make
run: echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: autoreconf -iv
run: autoreconf -iv
- name: ./configure
run: ./configure
- name: make distcheck
run: make distcheck
name: Ubuntu

on: push

jobs:
build:
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: install updates
run: sudo apt-get update
- name: install build system
run: sudo apt-get install -y autoconf autoconf-archive automake pkg-config libtool libtool-bin libltdl-dev doxygen gcc yasm
- name: install dependencies
run: sudo apt-get install -y libasound2-dev libaudio-dev libjack-jackd2-dev libopenal-dev libpulse-dev libsdl1.2-dev libsdl2-dev libsndio-dev portaudio19-dev
- name: setup parallel make
run: echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: autoreconf -iv
run: autoreconf -iv
- name: ./configure
run: ./configure
- name: make distcheck
run: make distcheck
30 changes: 30 additions & 0 deletions .github/workflows/cron-git.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on:
schedule:
- cron: "0 * * * *" # Run every hour

jobs:
git_svn_sync:
if: ${{ github.repository == 'madebr/mpg123' }}
runs-on: "ubuntu-latest"
steps:
- name: "Checkout git mpg123 clone"
uses: "actions/checkout@v4"
with:
fetch-depth: 0
token: ${{ secrets.PUSH_GITHUB_TOKEN }}
- name: "Configure git client"
run: |
git config --global user.name "mpg123 GitHub bot"
git config --global user.email "[email protected]"
- name: "Download (new) revisions from mpg123 git-svn"
run: |
git remote add mpg123 https://mpg123.org/trunk/.git/
git fetch mpg123
- name: "Merge mpg123's master"
run: |
git checkout master-with-github-ci
git merge mpg123/master -X ours
- name: "Force push (new) master"
run: |
git push origin master-with-github-ci -f
git push origin mpg123/master:master -f
Loading

0 comments on commit abc1586

Please sign in to comment.