chore: support pytest #585
Workflow file for this run
This file contains 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
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
test: | |
strategy: | |
matrix: | |
scaffold-version: | |
- v0.3.0 | |
preset: | |
- kitchen-sink | |
- java | |
- js | |
- go | |
- py | |
- cpp | |
- rust | |
- minimal | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: bazel-contrib/setup-bazel@0.9.0 | |
with: | |
bazelisk-cache: true | |
repository-cache: true | |
- uses: jaxxstorm/action-install-gh-release@25d5e2dd555cd74f1fab9ac1e6ea117acde2c0c4 # v1.12.0 | |
with: | |
repo: hay-kot/scaffold | |
tag: ${{ matrix.scaffold-version }} | |
- name: setting to always run hooks | |
if: "${{ matrix.preset != 'minimal' }}" | |
run: echo "SCAFFOLD_SETTINGS_RUN_HOOKS=always" >> "$GITHUB_ENV" | |
- name: Scaffold new app | |
id: scaffold | |
run: | | |
scaffold new --preset=${{ matrix.preset }} --no-prompt $GITHUB_WORKSPACE | |
cd scaffold_test* | |
git init | |
git add . | |
git config user.email "noreply@aspect.build" | |
git config user.name "No One" | |
git commit -a -m "initial commit" | |
echo "dir=$PWD" >> $GITHUB_OUTPUT | |
- run: bazel test ... | |
working-directory: "${{ steps.scaffold.outputs.dir }}" | |
- run: bazel run format | |
working-directory: "${{ steps.scaffold.outputs.dir }}" | |
if: "${{ matrix.preset != 'minimal' }}" | |
- name: format made no changes | |
working-directory: "${{ steps.scaffold.outputs.dir }}" | |
run: git diff --exit-code | |
- name: Tools smoke test | |
run: | | |
./tools/copier --help | |
./tools/yq --help | |
working-directory: "${{ steps.scaffold.outputs.dir }}" | |
if: "${{ matrix.preset == 'kitchen-sink' }}" | |
- name: Python smoke test | |
run: | | |
mkdir app | |
>app/__main__.py echo -e 'import requests\nprint(requests.get("https://api.github.com").text)' | |
>app/app_test.py echo -e 'test_bad():\n assert 1 == 2' | |
sed -i 's/dependencies = \[/dependencies = ["requests",/' pyproject.toml | |
./repin.sh | |
bazel run //app:app_bin | |
bazel test //app:app_test | |
working-directory: "${{ steps.scaffold.outputs.dir }}" | |
if: "${{ matrix.preset == 'py' }}" | |
- name: Go smoke test | |
run: ./tools/go mod tidy | |
working-directory: "${{ steps.scaffold.outputs.dir }}" | |
if: "${{ matrix.preset == 'go' }}" | |
- name: JS smoke test | |
run: ./tools/pnpm list | |
working-directory: "${{ steps.scaffold.outputs.dir }}" | |
if: "${{ matrix.preset == 'js' }}" | |
- name: Rust smoke test | |
run: | | |
mkdir -p hello_world/src | |
cat >hello_world/BUILD.bazel <<EOF | |
load("@rules_rust//rust:defs.bzl", "rust_binary") | |
rust_binary( | |
name = "hello_world", | |
srcs = ["src/main.rs"], | |
) | |
EOF | |
cat >hello_world/src/main.rs <<EOF | |
fn main() { println!("Hello from Rust"); } | |
EOF | |
output="$(bazel run //hello_world)" | |
[[ "${output}" == "Hello from Rust" ]] || { echo >&2 "Wanted output 'Hello from Rust' but got '${output}'" ; exit 1 ; } | |
working-directory: "${{ steps.scaffold.outputs.dir }}" | |
if: "${{ matrix.preset == 'rust' }}" | |
- run: bazel lint ... | |
working-directory: "${{ steps.scaffold.outputs.dir }}" | |
# For branch protection settings, this job provides a "stable" name that can be used to gate PR merges | |
# on "all matrix jobs were successful". | |
conclusion: | |
needs: test | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- uses: technote-space/workflow-conclusion-action@45ce8e0eb155657ab8ccf346ade734257fd196a5 # v3.0.3 | |
# Note: possible conclusion values: | |
# https://github.com/technote-space/workflow-conclusion-action/blob/main/src/constant.ts | |
- name: report success | |
if: ${{ env.WORKFLOW_CONCLUSION == 'success' }} | |
working-directory: /tmp | |
run: echo ${{ env.WORKFLOW_CONCLUSION }} && exit 0 | |
- name: report failure | |
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' }} | |
working-directory: /tmp | |
run: echo ${{ env.WORKFLOW_CONCLUSION }} && exit 1 |