Rename main.yml to C#_Branch_Test.yml #1
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
name: Equation check 1 in C# | |
on: | |
push: | |
branches: | |
- C#_Version | |
pull_request: | |
branches: | |
- C#_Version | |
workflow_dispatch: #Allows Manual Triggering | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Set up .NET SDK | |
- name: Set up .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '9.0' | |
# Step 3: Restore dependencies | |
- name: Restore dependencies | |
run: dotnet restore | |
# Step 4: Build the project | |
- name: Build the project | |
run: dotnet build --configuration Release | |
# Step 5: Run tests | |
- name: Run tests | |
run: dotnet test | |
# Step 6: Test start here | |
- name: Run Linear Equation Solver for H2+O2=H2O | |
id: run_console | |
run: | | |
echo -e "2\n3\n2\n0\n-2\n0\n0\n2\n-1\n0" > input.txt | |
dotnet run --project "Linear Equation Solver(High Precision).csproj" < input.txt > output.log | |
if grep -q "x0 = 1/1" output.log && grep -q "x1 = 1/2" output.log && grep -q "x2 = 1/1" output.log; then | |
echo "Test for simple chemical equation succeeded." | |
echo "result=success" >> $GITHUB_ENV | |
else | |
echo "Test for simple chemical equation did not run as expected." | |
echo "result=failure" >> $GITHUB_ENV | |
fi | |
#add other test for later | |
# Step 8: Collect logs and display | |
- name: Error Log collection and display | |
if: env.result == 'failure' | |
run: | | |
echo "Collecting logs..." | |
cp output.log failure-details.log | |
echo "Test failed. Summary:" | |
cat failure-details.log | |
exit 1 |