I have written a program which takes in an single command line argument containing the input file, and runs it through some algorithms and creating a txtfile containing the results.
What I need to be able to do is review the file using GitHub Actions. My program builds with GitHub Actions, I just can't review the output files.
Currently this is how I have my cmake.yml set up:
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
And with regards to how I have written the textfiles within my program:
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;
}
The following code above is replicated cross three different classes and gets called in main.
As for how we have called for the input file:
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>();
}
This function is more extensive than this, but it gets called in main, and the data gets passed to the necessary algorithms.
Although it is building, when I review the build closer I get the following messages
Please execute this program with the input file name included as an argument.
and
Warning: No files were found with the provided path: /home/runner/work/22s-pa01-nicandpaige/22s-pa01-nicandpaige/build/output. No artifacts will be uploaded.
I am not to sure where exactly the problem lies as this is my first time writing a cmake.yml, and I have hit a block.
Any guidance would be greatly appreciated.
CodePudding user response:
This seems to be an error message emitted by your program:
Please execute this program with the input file name included as an argument.
We can't know what goes wrong because you don't show the part of your program that emits this.
You say
I have written a program which takes in an single command line argument
but you give multiple arguments:
${{env.INPUT_FILE}} ${{env.OUTPUT_FILE}}
You show the code line
myfile.open ("../output/test-highvalue.txt");
your working directory is ${{github.workspace}}/build, therefore your output directory is ${{github.workspace}}/output, not ${{github.workspace}}/build/output.
You don't show how you create the output directory.
To sum up: There are some fishy things but you don't give enough information for us to actually figure out what goes wrong.
