Skip to content

GitHub

Creating a github repo

  • To create a new repository in GitHub visit this page. Where you will need to select the correct owner, fill repository name, description, make it private and click "Create repository" button.
  • Add github remote and push all the changes git remote add origin git@github.com:vendorname/module-name.git. And push all the changes git push origin master

Releases

Creating a release

  • Go to your repository and click "Releases" tab
  • Then click the button "Create a new release"
  • Then in Tag version field insert version. You can read more about semantinc versioning here.
  • Fill in Release title, and write short description.
  • Once you have done all above steps. Press "Publish Release".

That is it, you have published your first release. To confirm that it's really published, visit your repository page "Releases" tab and you should see your newly created release.

Deleting a release

To delete a release click on release heading for example "Initial Release" and then click "Delete" button.

Editing a release

Click on release heading and then click "Edit Release" button.

Pull Requests

Creating Pull Requests in GitHub is a good way of ensuring that the tests you have setup are triggered before you merge any changes into the LIVE / master branch.

This will detail how to use them

Work on your branch

First you need to create your branch and work on it as you normally would.

Once the changes are ready to be merged in, push the branch up to GitHub.

Create the Pull Request

From the repo page on GitHub, click the Pull Requests link in the top menu.

This will take you to a page of open PRs.

Tip

When you push changes to GitHub it gives you the link to create a pull request.

Details here

Adding SSH Keys for accessing a repo

Info Here

Setting Up New GitHub Repo with Scrutinizer, Travis, CI, and PHPQA

Local setup

Once you've created your new repo

  1. Clone it down into a development container

Redacted

  1. Change Directory to your repo and create files and folder structure - adding git keeps to allow empty folders
  2. cd path/to/repo ; mkdir src ; mkdir tests ;
  3. touch src/.gitkeep;touch tests/.gitkeep;
  4. Create a README.md with the title of your project touch README.md; echo #Reponame > README.md;
  5. git add -A ./; git commit -m "Initial Commit"; git push origin master, Git add,commit & push back up to GitHub Remote

Redacted

  1. Copy the travis and ci configurations we use on other projects

    • .travis.yml
    • .scrutinizer.yml
    • qaConfig - copy folder and only ci/travis folder and just the phpstan.neon file.
    • ci.bash
  2. Run Composer require to set up composer files : composer require edmondscommerce/phpqa:dev-master@dev --dev

  3. Add to autoload and config to composer.json - config needed for ./bin/qa command.

      "autoload": {
        "psr-4": {
          "$YOURNAMESPACE\\": [
            "src"
          ]
        },
      },
      "autoload-dev": {
        "psr-4": {
          "$YOURNAMESPACE\\Tests\\": [
            "tests"
          ]
        }
      },
      "config": {
        "bin-dir": "bin"
      }
    

  4. Add your php files to src and tests to tests.

  5. Run ./bin/qa if errors then try and fix locally.

Github config and CI

  1. On git hub head over to the GitHub settings on your repo.

Github Settings Image

  1. Head to the branches Tab to configure checks for a branch on your repo.

  2. Give the branch name you want checks on, in this case it is master

    • Tick the "Require status checks to pass before merging" option.
    • Tick the "Require branches to be up to date before merging" option.
    • Tick the "Include administrators" option.
  3. For the status checks to work you now need to log into the status checks sites to configure them to hook into these requests.

Scrutinizer-CI

  • Add a new repository with the "+ Add Repository" button.
  • Fill the github repository - it will auto-fill if connected with your github.
  • Select the language
  • Do not tick option for the Tests/Coverage Label - We've added these ourselves.

After CI integrated

Once the following steps have been set up it's time to test they work.

  • Create a new branch on you're repo
  • Make some edits - ie. fix test coverage
  • Push new branch to remote
  • Check the pull request link in the command line, when pushed.
    • If there isn't one then log into github and make a new one

You should now see before allowing you to merge the branch that the status checks are running and if failed will not allow you to merge.