如何在 github 动作中使用自己的 Makefile?

How to use your own Makefile in github actions?

我正在尝试使用 github 操作自动化 CI/CD 管道。我有一个 Makefile 如下:

.virtualenv:
    virtualenv -p python3 .virtualenv
    . .virtualenv/bin/activate; \
    pip install -r requirements.txt -r requirements_test.txt

clean:
    find . -name __pycache__ -exec rm -rf {} +
    rm -rf *.egg-info
    rm -rf .virtualenv/


test: .virtualenv
    (. .virtualenv/bin/activate; \
    pycodestyle --max-line-length=79 app test; \
    nosetests --with-coverage --cover-tests --cover-min-percentage=80 --cover-package=app test)

build: test clean

.PHONY: test clean

我想使用 github 操作来自动化此工作流程。我已经像这样设置了我的 github 工作流程:

name: python-app

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - name: build application
      run: make build

我想要的是当推送到 master 或针对 master 创建 PR 时,应该触发工作流。我知道这里有一个测试 python 应用程序的标准模板:https://docs.github.com/en/actions/guides/building-and-testing-python#testing-your-code 但我想通过我自己的 Makefile 来完成。当我 运行 这个我得到这个错误:

每一步都必须定义一个 usesrun

这方面的任何线索都会有所帮助。谢谢

当你想从当前版本库执行文件时,你需要使用actions/checkout

这将允许您在工作流程中访问存储库 $github_workspaceGithub environment variables 之一)。

例如,考虑到您的 Makefile 文件位于存储库的根目录中,您可以使用如下内容:

   name: python-app

   on:
     push:
       branches: [ master ]
     pull_request:
       branches: [ master ]

   jobs:
    build:
      runs-on: ubuntu-latest
      steps:
      - name: checkout repo
        uses: actions/checkout@v2
      - name: build application
        run: make build

Here 是来自个人存储库的另一个工作流示例,如果您想执行特定脚本来执行任何操作,遵循相同的逻辑。