From 7c24354c8068060af9ca522888e10395fa2c80bb Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Mon, 24 Mar 2025 11:51:57 -0500 Subject: [PATCH 01/11] Set up GitHub Actions to build project --- .github/workflows/run-app.yaml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml index 6ec58bc2..1b520287 100644 --- a/.github/workflows/run-app.yaml +++ b/.github/workflows/run-app.yaml @@ -1,10 +1,19 @@ -name: 'Basic Action' +name: 'Run App Garrett Wilcoxen' -on: [push] +on: [push, pull_request] jobs: check-bats-version: runs-on: ubuntu-latest steps: - - name: Basic Action - run: echo "Hello, World!" \ No newline at end of file + - uses: actions/checkout@v2 + - uses: actions/setup-dotnet@v1 + with: + dotnet-version: '5.0.301' + - uses: nuget/setup-nuget@v1 + - name: Nuget Restore + run: nuget restore GithubActions.sln + - name: Install dependencies + run: dotnet restore GithubActions.sln + - name: Build + run: msbuild /p:Configuration=Release GithubActions.sln \ No newline at end of file From f33460bae645b487b39bfea86139593d5ad14cbe Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Mon, 24 Mar 2025 12:03:38 -0500 Subject: [PATCH 02/11] Trigger workflow run --- .github/workflows/run-app.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml index 1b520287..df9129fd 100644 --- a/.github/workflows/run-app.yaml +++ b/.github/workflows/run-app.yaml @@ -1,4 +1,4 @@ -name: 'Run App Garrett Wilcoxen' +name: 'Run App Garrett Wilcoxen' on: [push, pull_request] From 2e48b7de9d8cdd5877229cdb340734dcb659ad5a Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Mon, 24 Mar 2025 12:10:21 -0500 Subject: [PATCH 03/11] Updated workflow to build Console App --- .github/workflows/run-app.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml index df9129fd..1b520287 100644 --- a/.github/workflows/run-app.yaml +++ b/.github/workflows/run-app.yaml @@ -1,4 +1,4 @@ -name: 'Run App Garrett Wilcoxen' +name: 'Run App Garrett Wilcoxen' on: [push, pull_request] From ca5ede5dbaef54e25861136914bbba7c8a3b0d4c Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Mon, 24 Mar 2025 12:12:05 -0500 Subject: [PATCH 04/11] Removed nuget restore, using dotnet restore instead --- .github/workflows/run-app.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml index 1b520287..b0ec6d19 100644 --- a/.github/workflows/run-app.yaml +++ b/.github/workflows/run-app.yaml @@ -10,10 +10,7 @@ jobs: - uses: actions/setup-dotnet@v1 with: dotnet-version: '5.0.301' - - uses: nuget/setup-nuget@v1 - - name: Nuget Restore - run: nuget restore GithubActions.sln - name: Install dependencies run: dotnet restore GithubActions.sln - name: Build - run: msbuild /p:Configuration=Release GithubActions.sln \ No newline at end of file + run: msbuild /p:Configuration=Release GithubActions.sln From f413466709e8b98b03a902ffd57bc607579c53cb Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Mon, 24 Mar 2025 12:13:50 -0500 Subject: [PATCH 05/11] Switch to .NET 6 to fix restore error --- .github/workflows/run-app.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml index b0ec6d19..038403cf 100644 --- a/.github/workflows/run-app.yaml +++ b/.github/workflows/run-app.yaml @@ -9,8 +9,8 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '5.0.301' + dotnet-version: '6.0.x' - name: Install dependencies run: dotnet restore GithubActions.sln - name: Build - run: msbuild /p:Configuration=Release GithubActions.sln + run: dotnet build GithubActions.sln --configuration Release From beccf1aaae68c4ae49b197d366820f7d8335b130 Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Wed, 26 Mar 2025 15:48:16 -0500 Subject: [PATCH 06/11] Working .NET 8 build with passing MSTest tests --- Console/Console.csproj | 76 ++------------------------ Console/Properties/AssemblyInfo.cs | 36 ------------ Tests/Properties/AssemblyInfo.cs | 36 ------------ Tests/Tests.csproj | 88 ++++-------------------------- Tests/UnitTests.cs | 26 ++++----- 5 files changed, 30 insertions(+), 232 deletions(-) delete mode 100644 Console/Properties/AssemblyInfo.cs delete mode 100644 Tests/Properties/AssemblyInfo.cs diff --git a/Console/Console.csproj b/Console/Console.csproj index 939964bd..21114b11 100644 --- a/Console/Console.csproj +++ b/Console/Console.csproj @@ -1,74 +1,8 @@ - - - + + - Debug - AnyCPU - {C5964EEF-DA27-4C98-B4D0-7F27767FE870} Exe - TravisCI - TravisCI - v4.8 - 512 - true - - - + net8.0 - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Microsoft.Build.Framework.17.1.0\lib\net472\Microsoft.Build.Framework.dll - - - ..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.3.0.4492\lib\net35\Microsoft.VisualStudio.Setup.Configuration.Interop.dll - True - - - - - ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file + + diff --git a/Console/Properties/AssemblyInfo.cs b/Console/Properties/AssemblyInfo.cs deleted file mode 100644 index 92fc8138..00000000 --- a/Console/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TravisCI")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("TravisCI")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c5964eef-da27-4c98-b4d0-7f27767fe870")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/Properties/AssemblyInfo.cs b/Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 2e2b2f68..00000000 --- a/Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Tests")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Tests")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c3f293d9-3d79-4280-9e67-9e51a00e94f3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 995b5561..3d95b93c 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -1,82 +1,18 @@ - - - - + + - Debug - AnyCPU - {C3F293D9-3D79-4280-9E67-9E51A00E94F3} - Library - Properties - Tests - Tests - v4.8 - 512 - - - + net8.0 + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\Microsoft.Build.Framework.17.1.0\lib\net472\Microsoft.Build.Framework.dll - - - ..\packages\Microsoft.VisualStudio.Setup.Configuration.Interop.3.0.4492\lib\net35\Microsoft.VisualStudio.Setup.Configuration.Interop.dll - True - - - ..\packages\NUnit.3.9.0\lib\net45\nunit.framework.dll - - - - - ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll - - - - - - - - - - - - - + - + + + + - - {c5964eef-da27-4c98-b4d0-7f27767fe870} - Console - + - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file + + diff --git a/Tests/UnitTests.cs b/Tests/UnitTests.cs index 5d5f6f41..90de1325 100644 --- a/Tests/UnitTests.cs +++ b/Tests/UnitTests.cs @@ -1,12 +1,12 @@ using System; -using NUnit.Framework; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace GithubActionsLab { - [TestFixture] - public class Math + [TestClass] + public class MathTests { - [Test] + [TestMethod] public void Add_Valid() { Assert.AreEqual(3, Program.Add("1", "2")); @@ -14,22 +14,22 @@ public void Add_Valid() Assert.AreEqual(12, Program.Add("5", "7")); } - [Test] + [TestMethod] public void Add_Invalid() { - Assert.Throws(() => Program.Add("1", "a")); - Assert.Throws(() => Program.Add("a", "1")); - Assert.Throws(() => Program.Add("a", "a")); + Assert.ThrowsException(() => Program.Add("1", "a")); + Assert.ThrowsException(() => Program.Add("a", "1")); + Assert.ThrowsException(() => Program.Add("a", "a")); } - [Test] + [TestMethod] public void Add_Null() { - Assert.Throws(() => Program.Add("1", null)); - Assert.Throws(() => Program.Add(null, "1")); - Assert.Throws(() => Program.Add(null, null)); + Assert.ThrowsException(() => Program.Add("1", null)); + Assert.ThrowsException(() => Program.Add(null, "1")); + Assert.ThrowsException(() => Program.Add(null, null)); } - // Implement 3 tests per operation, following a similar pattern as above + // You can add more [TestMethod]s for Subtract, Multiply, Divide, Power, etc. } } From 6de09e09d831f3f9a15eb7b5d847ae7406eb4e2d Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Wed, 26 Mar 2025 15:50:29 -0500 Subject: [PATCH 07/11] Fix workflow to use .NET 8 --- .github/workflows/run-app.yaml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml index 038403cf..4e430fde 100644 --- a/.github/workflows/run-app.yaml +++ b/.github/workflows/run-app.yaml @@ -1,16 +1,25 @@ -name: 'Run App Garrett Wilcoxen' +name: 'Run App Wilcoxen, Garrett' on: [push, pull_request] jobs: - check-bats-version: + build-and-test: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v2 - - uses: actions/setup-dotnet@v1 + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.x' - - name: Install dependencies - run: dotnet restore GithubActions.sln + dotnet-version: '8.0.x' + + - name: Restore dependencies + run: dotnet restore + - name: Build - run: dotnet build GithubActions.sln --configuration Release + run: dotnet build --no-restore + + - name: Test + run: dotnet test --no-build --verbosity normal From c28250d4d74f1c2d498716c8025b5f110fdceb36 Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Wed, 26 Mar 2025 15:52:50 -0500 Subject: [PATCH 08/11] Add build status badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a17b113..5c993e86 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Run App](https://github.com/kgerot/GithubActions/actions/workflows/run-app.yaml/badge.svg)](https://github.com/kgerot/GithubActions/actions/workflows/run-app.yaml) +[![Run App Wilcoxen, Garrett](https://github.com/gwilcoxen/GithubActions/actions/workflows/run-app.yaml/badge.svg)](https://github.com/gwilcoxen/GithubActions/actions/workflows/run-app.yaml) # Do not submit a pull request to `kgerot/GithubActions` or `dteske/TraviCI`. Not following this instruction can ruin the lab for others, so pay attention. From 10db6b4d99d4534e03fce1e2c710620cb2bf9dbf Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Wed, 26 Mar 2025 15:59:14 -0500 Subject: [PATCH 09/11] Implemented Power method --- Console/Program.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Console/Program.cs b/Console/Program.cs index 9be02228..a450e2bb 100644 --- a/Console/Program.cs +++ b/Console/Program.cs @@ -53,7 +53,6 @@ static void Main(string[] args) { Console.WriteLine(e.Message); } - } } @@ -72,22 +71,24 @@ public static double Subtract(string x, string y) { return double.Parse(x) - double.Parse(y); } + public static double Multiply(string x, string y) { return double.Parse(x) * double.Parse(y); } + public static double Divide(string x, string y) { return double.Parse(x) / double.Parse(y); } - // Implement this method following a similar pattern as above + // ✅ Implemented Power method public static double Power(string x, string y) { - throw new NotImplementedException(); + if (x == null || y == null) + throw new ArgumentNullException(); + + return Math.Pow(double.Parse(x), double.Parse(y)); } } - - - } From 85aa8e93d30f2a771052484243656835e6abfce5 Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Wed, 26 Mar 2025 16:04:51 -0500 Subject: [PATCH 10/11] Add unit tests for Power method --- Tests/UnitTests.cs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Tests/UnitTests.cs b/Tests/UnitTests.cs index 90de1325..653b1273 100644 --- a/Tests/UnitTests.cs +++ b/Tests/UnitTests.cs @@ -30,6 +30,28 @@ public void Add_Null() Assert.ThrowsException(() => Program.Add(null, null)); } - // You can add more [TestMethod]s for Subtract, Multiply, Divide, Power, etc. + [TestMethod] + public void Power_Valid() + { + Assert.AreEqual(8, Program.Power("2", "3")); + Assert.AreEqual(1, Program.Power("5", "0")); + Assert.AreEqual(10000, Program.Power("10", "4")); + } + + [TestMethod] + public void Power_Invalid() + { + Assert.ThrowsException(() => Program.Power("a", "3")); + Assert.ThrowsException(() => Program.Power("2", "b")); + Assert.ThrowsException(() => Program.Power("x", "y")); + } + + [TestMethod] + public void Power_Null() + { + Assert.ThrowsException(() => Program.Power(null, "3")); + Assert.ThrowsException(() => Program.Power("2", null)); + Assert.ThrowsException(() => Program.Power(null, null)); + } } } From 588565b026a36fae83bc51700f8c4ee967b07e93 Mon Sep 17 00:00:00 2001 From: Garrett Wilcoxen Date: Wed, 26 Mar 2025 16:08:01 -0500 Subject: [PATCH 11/11] Trigger CI on PR by touching workflow --- .github/workflows/run-app.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-app.yaml b/.github/workflows/run-app.yaml index 4e430fde..a08fafef 100644 --- a/.github/workflows/run-app.yaml +++ b/.github/workflows/run-app.yaml @@ -23,3 +23,4 @@ jobs: - name: Test run: dotnet test --no-build --verbosity normal + \ No newline at end of file