Merge pull request #159 from python-project-templates/tkp/use-copier-… #340
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Status | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| checks: write | |
| pull-requests: write | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| template: | |
| - python | |
| - cpp | |
| - js | |
| - jupyter | |
| - rust | |
| - rustjswasm | |
| - cppjswasm | |
| os: | |
| - ubuntu-latest | |
| - macos-latest | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - name: Create fixture files | |
| run: | | |
| # python | |
| touch pyproject.toml | |
| # node | |
| echo '{"name": "a", "version": "0.0.0", "scripts": {}}' > package.json | |
| printf 'lockfileVersion: '9.0'\nsettings:\n\tautoInstallPeers: true\n\texcludeLinksFromLockfile: false\nimporters:\n.: {}' > pnpm-lock.yaml | |
| # rust | |
| printf '[package]\nname = "rust"\nversion = "0.1.0"\nedition = "2021"\n[dependencies]\n' > Cargo.toml | |
| mkdir -p src | |
| printf 'fn main() {\n println!("Hello, world!");\n}\n' > src/main.rs | |
| - name: Setup Python | |
| uses: actions-ext/python/setup@6e1b91a408ea89f49bc8aff8724f83826f7b5446 | |
| with: | |
| version: '3.11' | |
| - name: Install Copier | |
| run: uv pip install copier | |
| - name: Install clang-format | |
| run: | | |
| if [[ "$RUNNER_OS" == "Linux" ]]; then | |
| sudo apt-get install -y clang-format-14 | |
| sudo ln -sf /usr/bin/clang-format-14 /usr/bin/clang-format | |
| elif [[ "$RUNNER_OS" == "macOS" ]]; then | |
| brew install clang-format | |
| fi | |
| if: matrix.template == 'cpp' || matrix.template == 'cppjswasm' | |
| - name: Setup Node.js | |
| uses: actions-ext/node/setup@0ea5bdcd24d2488b28e16bf611b446a2f8e1e12f | |
| with: | |
| version: 22.x | |
| pnpm_version: 11.11.0 | |
| js_folder: "." | |
| if: matrix.template == 'js' || matrix.template == 'jupyter' || matrix.template == 'cppjswasm' || matrix.template == 'rustjswasm' | |
| - name: Setup Rust | |
| uses: actions-ext/rust/setup@2db8e3e4c56beb7320c7d730bd2c2d6a6447bf6b | |
| if: matrix.template == 'rust' || matrix.template == 'rustjswasm' | |
| - name: Install JavaScript dependencies | |
| run: pnpm install | |
| if: matrix.template == 'js' || matrix.template == 'jupyter' || matrix.template == 'cppjswasm' || matrix.template == 'rustjswasm' | |
| - name: Build Rust fixture | |
| run: cargo build | |
| if: matrix.template == 'rust' || matrix.template == 'rustjswasm' | |
| - name: Generate and test template | |
| run: | | |
| make gen-${{matrix.template}} | |
| make test-${{matrix.template}} |