name: CI (Alpine)

on:
  push:
    branches:
      - master
  pull_request:
  merge_group:
  workflow_dispatch:
  schedule:
    - cron: '0 0 1 * *'

jobs:
  alpine:

    strategy:
      fail-fast: false
      matrix:
        include:
        - alpine: 'edge'
#        - alpine: 'latest-stable'

    runs-on: ubuntu-latest
    name: alpine-${{ matrix.alpine }}

    concurrency:
      group: ${{ github.workflow }}-alpine-${{ matrix.alpine }}-${{ github.head_ref || github.run_id }}
      cancel-in-progress: true

    steps:
    - uses: actions/checkout@v4
      with:
        submodules: recursive
    - uses: jirutka/setup-alpine@v1
      with:
        branch: ${{ matrix.alpine }}
        extra-repositories: https://dl-cdn.alpinelinux.org/alpine/edge/testing
        packages: rocq dune  bash python3 graphviz  make findutils diffutils grep rsync
    - name: 'dune build @stdlib-html # depends on stdlib'
      shell: alpine.sh {0}
      run: 'dune build @stdlib-html # depends on stdlib'
    - name: 'find _build/default/doc/stdlib/html/ -iname "*\**" -print -delete # for upload-artifact'
      shell: alpine.sh {0}
      run: 'find _build/default/doc/stdlib/html/ -iname "*\**" -print -delete # for upload-artifact'
    - uses: actions/upload-artifact@v4
      with:
        name: stdlib-html
        path: _build/default/doc/stdlib/html
    - name: Check for duplicate files
      shell: alpine.sh {0}
      run: dev/tools/check-duplicate-files.sh
