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

我正在尝试使用 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_workspace(Github 环境变量之一)。

例如,考虑到您的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

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


以上是如何在github操作中使用自己的Makefile?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>