diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f0a00c4f..c3cc16de 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -26,47 +26,50 @@ Discussion of issues should be placed transparently in the issue tracker here on * [AngleSharp.Core](https://github.com/AngleSharp/AngleSharp/issues/) * [AngleSharp.Css](https://github.com/AngleSharp/AngleSharp.Css/issues/) +* [AngleSharp.Diffing](https://github.com/AngleSharp/AngleSharp.Diffing/issues/) * [AngleSharp.Io](https://github.com/AngleSharp/AngleSharp.Io/issues/) * [AngleSharp.Js](https://github.com/AngleSharp/AngleSharp.Js/issues/) * [AngleSharp.Xml](https://github.com/AngleSharp/AngleSharp.Xml/issues/) +* [AngleSharp.XPath](https://github.com/AngleSharp/AngleSharp.XPath/issues/) +* [AngleSharp.Wasm](https://github.com/AngleSharp/AngleSharp.Wasm/issues/) ### Modifying the code AngleSharp and its libraries uses features from the latest versions of C# (e.g., C# 7). You will therefore need a C# compiler that is up for the job. 1. Fork and clone the repo. -2. First try to build the AngleSharp.Core libray and see if you get the tests running. +2. First try to build the AngleSharp.Core library and see if you get the tests running. 3. You will be required to resolve some dependencies via NuGet. AngleSharp itself does not have dependencies, however, the tests are dependent on NUnit. -The build system of AngleSharp uses Cake. A bootstrap script (build.ps1 for Windows or build.sh for *nix systems) is included. Note, that at the moment AngleSharp may require NuGet 3.5, which looks for MSBuild pre-15, i.e., before Visual Studio 2017 on Windows systems. We aim to drop this requirement enitirely soon. +The build system of AngleSharp uses Cake. A bootstrap script (build.ps1 for Windows or build.sh for *nix systems) is included. Note, that at the moment AngleSharp may require NuGet 3.5, which looks for MSBuild pre-15, i.e., before Visual Studio 2017 on Windows systems. We aim to drop this requirement entirely soon. ### Code Conventions Most parts in the AngleSharp project are fairly straight forward. Among these are: -- Always use statement blocks for control statements, e.g., in a for-loop, if-condition, ... -- You may use a simple (throw) statement in case of enforcing contracts on argument -- Be explicit about modifiers (some files follow an older convention of the code base, but we settled on the explicit style) +* Always use statement blocks for control statements, e.g., in a for-loop, if-condition, ... +* You may use a simple (throw) statement in case of enforcing contracts on argument +* Be explicit about modifiers (some files follow an older convention of the code base, but we settled on the explicit style) There are a couple of rules, which are definitely not standard, but highly recommended for consistency and readability: -- AngleSharp uses the RHS convention, where types are always put on the right hand side if possible, i.e., preferring `var` under all circumstances -- A single empty line between two non-simple statements (e.g., for-loop and if-condition) should be inserted -- Types are preferred to keywords (`String` instead of `string` or `Int32` instead of `int`) -- `using` statements must be inside the namespace declaration +* AngleSharp uses the RHS convention, where types are always put on the right hand side if possible, i.e., preferring `var` under all circumstances +* A single empty line between two non-simple statements (e.g., for-loop and if-condition) should be inserted +* Types are preferred to keywords (`String` instead of `string` or `Int32` instead of `int`) +* `using` statements must be inside the namespace declaration ### Development Workflow 1. If no issue already exists for the work you'll be doing, create one to document the problem(s) being solved and self-assign. 2. Otherwise please let us know that you are working on the problem. Regular status updates (e.g. "still in progress", "no time anymore", "practically done", "pull request issued") are highly welcome. -2. Create a new branch—please don't work in the `master` branch directly. It is reserved for releases. We recommend naming the branch to match the issue being addressed (`feature/#777` or `issue-777`). -3. Add failing tests for the change you want to make. Tests are crucial and should be taken from W3C (or other specification). -4. Fix stuff. Always go from edge case to edge case. -5. All tests should pass now. Also your new implementation should not break existing tests. -6. Update the documentation to reflect any changes. (or document such changes in the original issue) -7. Push to your fork or push your issue-specific branch to the main repository, then submit a pull request against `devel`. +3. Create a new branch—please don't work in the `master` branch directly. It is reserved for releases. We recommend naming the branch to match the issue being addressed (`feature/#777` or `issue-777`). +4. Add failing tests for the change you want to make. Tests are crucial and should be taken from W3C (or other specification). +5. Fix stuff. Always go from edge case to edge case. +6. All tests should pass now. Also your new implementation should not break existing tests. +7. Update the documentation to reflect any changes. (or document such changes in the original issue) +8. Push to your fork or push your issue-specific branch to the main repository, then submit a pull request against `devel`. Just to illustrate the git workflow for AngleSharp a little bit more we've added the following graphs. @@ -76,19 +79,19 @@ Here we now created a new branch called `devel`. This is the development branch. Now active work is supposed to be done. Therefore a new branch should be created. Let's create one: -``` +```sh git checkout -b feature/#777 ``` There may be many of these feature branches. Most of them are also pushed to the server for discussion or synchronization. -``` +```sh git push -u origin feature/#777 ``` Now feature branches may be closed when they are done. Here we simply merge with the feature branch(es). For instance the following command takes the `feature/#777` branch from the server and merges it with the `devel` branch. -``` +```sh git checkout devel git pull git pull origin feature/#777 @@ -97,7 +100,7 @@ git push Finally, we may have all the features that are needed to release a new version of AngleSharp. Here we tag the release. For instance for the 1.0 release we use `v1.0`. -``` +```sh git checkout master git merge devel git tag v1.0 @@ -109,12 +112,11 @@ git tag v1.0 The following files should not be edited directly in the current repository, but rather in the `AngleSharp.GitBase` repository. They are then synced via `git pull` from a different remote. -``` +```plaintext .editorconfig .gitignore .gitattributes .github/* -appveyor.yml build.ps1 build.sh tools/anglesharp.cake @@ -124,7 +126,7 @@ LICENSE To sync manually: -``` +```sh git remote add gitbase git@github.com:AngleSharp/AngleSharp.GitBase.git git pull gitbase master ``` diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..1f114d6f --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +github: FlorianRappl +custom: https://salt.bountysource.com/teams/anglesharp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..1d0bca6f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: [push, pull_request] + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + +jobs: + linux: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Build + run: ./build.sh + + windows: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + + - name: Build + run: | + if ($env:GITHUB_REF -eq "refs/heads/master") { + .\build.ps1 -Target Publish + } elseif ($env:GITHUB_REF -eq "refs/heads/devel") { + .\build.ps1 -Target PrePublish + } else { + .\build.ps1 + } diff --git a/LICENSE b/LICENSE index c2b5b2bb..fddded29 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013 - 2019 AngleSharp +Copyright (c) 2013 - 2021 AngleSharp Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 6e6985f6..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,20 +0,0 @@ -version: '{build}' -branches: - only: - - master - - devel -skip_tags: true -image: Visual Studio 2015 -configuration: Release -platform: Any CPU -build_script: -- ps: >- - if ($env:APPVEYOR_PULL_REQUEST_NUMBER -eq $null -and $env:APPVEYOR_REPO_BRANCH -eq "master") { - .\build.ps1 -Target Publish - } elseif ($env:APPVEYOR_PULL_REQUEST_NUMBER -eq $null -and $env:APPVEYOR_REPO_BRANCH -eq "devel") { - .\build.ps1 -Target PrePublish - } else { - .\build.ps1 -Target AppVeyor - } -test: off -deploy: off diff --git a/build.ps1 b/build.ps1 index 61a9f117..6f27bfdf 100644 --- a/build.ps1 +++ b/build.ps1 @@ -26,17 +26,17 @@ $NUGET_OLD_URL = "https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe" # Should we use experimental build of Roslyn? $UseExperimental = ""; if ($Experimental.IsPresent) { - $UseExperimental = "-experimental" + $UseExperimental = "--experimental" } # Is this a dry run? if ($WhatIf.IsPresent) { - $UseDryRun = "-dryrun" + $UseDryRun = "--dryrun" } # Should we use mono? if ($Mono.IsPresent) { - $UseMono = "-mono" + $UseMono = "--mono" } # Try download NuGet.exe if do not exist. @@ -77,5 +77,5 @@ if (!(Test-Path $CAKE_EXE)) { } # Start Cake -Invoke-Expression "$CAKE_EXE `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" +Invoke-Expression "$CAKE_EXE `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" exit $LASTEXITCODE \ No newline at end of file diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 index 41923b49..c62ce5c1 --- a/build.sh +++ b/build.sh @@ -27,7 +27,7 @@ for i in "$@"; do -t|--target) TARGET="$2"; shift ;; -c|--configuration) CONFIGURATION="$2"; shift ;; -v|--verbosity) VERBOSITY="$2"; shift ;; - -d|--dryrun) DRYRUN="-dryrun" ;; + -d|--dryrun) DRYRUN="--dryrun" ;; --version) SHOW_VERSION=true ;; --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; *) SCRIPT_ARGUMENTS+=("$1") ;; @@ -87,7 +87,7 @@ fi # Start Cake if $SHOW_VERSION; then - exec mono $CAKE_EXE -version + exec mono $CAKE_EXE --version else - exec mono $CAKE_EXE $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" + exec mono $CAKE_EXE $SCRIPT --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" fi \ No newline at end of file diff --git a/tools/anglesharp.cake b/tools/anglesharp.cake index bb2e14a0..09988d9b 100644 --- a/tools/anglesharp.cake +++ b/tools/anglesharp.cake @@ -5,23 +5,32 @@ using Octokit; var configuration = Argument("configuration", "Release"); var isRunningOnUnix = IsRunningOnUnix(); var isRunningOnWindows = IsRunningOnWindows(); -var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor; -var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest; -var buildNumber = AppVeyor.Environment.Build.Number; +var isRunningOnGitHubActions = BuildSystem.GitHubActions.IsRunningOnGitHubActions; var releaseNotes = ParseReleaseNotes("./CHANGELOG.md"); var version = releaseNotes.Version.ToString(); var buildDir = Directory($"./src/{projectName}/bin") + Directory(configuration); var buildResultDir = Directory("./bin") + Directory(version); var nugetRoot = buildResultDir + Directory("nuget"); -if (target == "PrePublish") +if (isRunningOnGitHubActions) { - version = $"{version}-alpha-{buildNumber}"; + var buildNumber = BuildSystem.GitHubActions.Environment.Workflow.RunNumber; + + if (target == "Default") + { + version = $"{version}-ci-{buildNumber}"; + } + else if (target == "PrePublish") + { + version = $"{version}-alpha-{buildNumber}"; + } } if (!isRunningOnWindows) { frameworks.Remove("net46"); + frameworks.Remove("net461"); + frameworks.Remove("net472"); } // Initialization @@ -74,13 +83,9 @@ Task("Run-Unit-Tests") Configuration = configuration, }; - if (isRunningOnAppVeyor) + if (isRunningOnGitHubActions) { - settings.TestAdapterPath = Directory("."); - settings.Logger = "Appveyor"; - // TODO Finds a way to exclude tests not allowed to run on appveyor - // Not used in current code - //settings.Where = "cat != ExcludeFromAppVeyor"; + settings.Loggers.Add("GitHubActions"); } DotNetCoreTest($"./src/{solutionName}.Tests/", settings); @@ -101,7 +106,10 @@ Task("Copy-Files") }, targetDir); } - CopyFiles(new FilePath[] { $"src/{projectName}.nuspec" }, nugetRoot); + CopyFiles(new FilePath[] { + $"src/{projectName}.nuspec", + "logo.png" + }, nugetRoot); }); Task("Create-Package") @@ -109,7 +117,6 @@ Task("Create-Package") .Does(() => { var nugetExe = GetFiles("./tools/**/nuget.exe").FirstOrDefault() - ?? (isRunningOnAppVeyor ? GetFiles("C:\\Tools\\NuGet3\\nuget.exe").FirstOrDefault() : null) ?? throw new InvalidOperationException("Could not find nuget.exe."); var nuspec = nugetRoot + File($"{projectName}.nuspec"); @@ -153,7 +160,7 @@ Task("Publish-Release") .IsDependentOn("Run-Unit-Tests") .Does(() => { - var githubToken = EnvironmentVariable("GITHUB_API_TOKEN"); + var githubToken = EnvironmentVariable("GITHUB_TOKEN"); if (String.IsNullOrEmpty(githubToken)) { @@ -175,14 +182,6 @@ Task("Publish-Release") }).Wait(); }); -Task("Update-AppVeyor-Build-Number") - .WithCriteria(() => isRunningOnAppVeyor) - .Does(() => - { - var num = AppVeyor.Environment.Build.Number; - AppVeyor.UpdateBuildVersion($"{version}-{num}"); - }); - // Targets // ---------------------------------------- @@ -194,12 +193,7 @@ Task("Default") .IsDependentOn("Package"); Task("Publish") - .IsDependentOn("Publish-Package") .IsDependentOn("Publish-Release"); Task("PrePublish") .IsDependentOn("Publish-Package"); - -Task("AppVeyor") - .IsDependentOn("Run-Unit-Tests") - .IsDependentOn("Update-AppVeyor-Build-Number"); diff --git a/tools/packages.config b/tools/packages.config index 89273716..e714645d 100644 --- a/tools/packages.config +++ b/tools/packages.config @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file