aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/.github/workflows/basic.yml
blob: 5477d4d0aaf50506955cc49c8448824836889483 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Basic usage

on:
  push:
  pull_request:
  schedule:
    # Weekly, at 5:30 AM on Saturday (somewhat randomly chosen).
    - cron: '30 5 * * 6'
  workflow_dispatch:

jobs:
  # Check that project-clang-format.py works (and the C/C++ files are formatted).
  lint:
    runs-on: ubuntu-latest
    name: Linting
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Run clang-format
        run: ./tools/project-clang-format.py

  # Check that the most basic use-case works on different OSs.
  os:
    strategy:
      matrix:
        os: [ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022, macos-11, macos-12]
        include:
          - boost-version: 1.78.0
    runs-on: '${{ matrix.os }}'
    name: 'Image: ${{ matrix.os }}'
    defaults:
      run:
        shell: pwsh
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.x'
      - name: Cache Boost
        uses: actions/cache@v3
        with:
          path: boost_*.tar.gz
          key: 'boost_${{ matrix.boost-version }}'
      - name: Build Boost
        run: |
          python -m project.boost.download --cache . '${{ matrix.boost-version }}' boost
          python -m project.boost.build -- boost --with-filesystem
      - name: Build example project
        run: |
          $src_dir = Join-Path examples boost
          python -m project.cmake.build --boost boost --install install -- $src_dir
      - name: Run example project
        run: ./.ci/run_foo.ps1 (Join-Path (Get-Location).Path install bin foo)

  # Check that the most basic use-case works w/ different Python versions.
  python-versions:
    strategy:
      matrix:
        python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
        include:
          # Unpin when this is fixed:
          # https://github.com/actions/setup-python/issues/544
          - os: ubuntu-20.04
          - boost-version: 1.78.0
    runs-on: '${{ matrix.os }}'
    name: 'Python ${{ matrix.python-version }}'
    defaults:
      run:
        shell: pwsh
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '${{ matrix.python-version }}'
      - name: Cache Boost
        uses: actions/cache@v3
        with:
          path: boost_*.tar.gz
          key: 'boost_${{ matrix.boost-version }}'
      - name: 'Install package & dependencies'
        run: pip install -q -e .
      - name: Check that scripts are runnable
        run: |
          boost-download --version
          boost-build --version
          cmake-build --version
      - name: Build Boost
        run: |
          boost-download --cache . '${{ matrix.boost-version }}' boost
          boost-build -- boost --with-filesystem
      - name: Build example project
        run: |
          $src_dir = Join-Path examples boost
          cmake-build --boost boost --install install -- $src_dir
      - name: Run example project
        run: ./.ci/run_foo.ps1 (Join-Path (Get-Location).Path install bin foo)

  # Build a Python package and upload to PyPI.
  publish:
    # TODO: figure out how to add a dependency on the *toolsets workflows.
    needs: [lint, os, python-versions]
    runs-on: ubuntu-latest
    name: Publish
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.x'
      - name: Verify package can be installed
        run: pip install -q .
      - name: Install package builder
        run: pip install -q --upgrade build
      - name: Build package
        run: python -m build
      - name: Publish as artifact
        uses: actions/upload-artifact@v3
        with:
          name: dist
          path: dist
          if-no-files-found: error
      - name: Publish to PyPI
        if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          user: __token__
          password: '${{ secrets.PYPI_API_TOKEN }}'