【发布时间】:2022-02-04 02:26:45
【问题描述】:
我编写了一个程序,它接受一个包含输入文件的命令行参数,并通过一些算法运行它并创建一个包含结果的 txtfile。
我需要做的是使用 GitHub Actions 查看文件。我的程序是使用 GitHub Actions 构建的,但我无法查看输出文件。
目前这是我设置 cmake.yml 的方式:
on:
push:
branches: [ main ]
env:
BUILD_TYPE: Debug
file's
TEST_EXE: 22s_pa01_nicandpaige
INPUT_FILE: input/input.txt
OUTPUT_FILE: output/test-highvalue.txt output/test-custom.txt. output/test-bruteforce
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v2
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Execute Project
working-directory: ${{github.workspace}}/build
run: ${{github.workspace}}/build/${{env.TEST_EXE}} ${{env.INPUT_FILE}} ${{env.OUTPUT_FILE}}
- name: Upload output files to GitHub so they can be reviewed
uses: actions/upload-artifact@v2
with:
name: project_output
path: ${{github.workspace}}/build/output
关于我如何在程序中编写文本文件:
std:: ofstream myfile;
myfile.open ("../output/test-highvalue.txt");
for (auto & i : x){
myfile << i.getId();
myfile << " ";
myfile << i.getValue();
totalValue += i.getValue();
myfile << " ";
myfile << i.getLength();
myfile << " ";
myfile << i.getH();
myfile << std:: endl;
}
以下代码跨三个不同的类复制并在 main 中调用。
至于我们如何调用输入文件:
std::vector<paintingData> read_paintings(char* arg){
std::ifstream inFS(arg);
if(!inFS.is_open()){
std::cout << "Failed to open " << arg << std::endl;
return std::vector<paintingData>();
}
这个函数比这个更广泛,但它在 main 中被调用,数据被传递给必要的算法。
虽然它正在构建,但当我仔细查看构建时,我会收到以下消息
请使用包含的输入文件名作为参数执行此程序。
和
警告:未找到具有以下路径的文件:/home/runner/work/22s-pa01-nicandpaige/22s-pa01-nicandpaige/build/output。不会上传任何工件。
我不确定问题出在哪里,因为这是我第一次编写 cmake.yml,我遇到了障碍。
任何指导将不胜感激。
【问题讨论】:
-
你确定你的 yaml 文件在语法上是正确的吗?我偶然发现了“文件”行,即恕我直言无效的 yaml。
标签: github cmake file-io yaml github-actions