Skip to content

Commit

Permalink
add sanity testing workflow and docs
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Wagner <h2floh@github.com>
  • Loading branch information
Florian Wagner committed Nov 22, 2022
1 parent b4b91e9 commit 8decd6c
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/actions-sync-e2e-test-called.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Actions Sync E2E Sanity Test Reusable

on:
workflow_call:
inputs:
runson:
type: string
required: true
secrets:
ghes_url:
required: true
actions_sync_releasedatetime:
required: true
site_admin_token:
required: true

jobs:
execute:
runs-on: ${{ inputs.runson }}
steps:
- uses: actions/checkout@v3
- name: Bootstrap
run: |
.\script\bootstrap-sanity-test.ps1
shell: pwsh
env:
RELEASEDATE: ${{ secrets.actions_sync_releasedatetime }}
- name: Test execution
run: |
.\script\execute-sanity-test.ps1
shell: pwsh
env:
TOKEN: ${{ secrets.site_admin_token }}
TEST_INSTANCE_URL: ${{ secrets.ghes_url }}
19 changes: 19 additions & 0 deletions .github/workflows/actions-sync-e2e-test-caller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Actions Sync E2E Sanity Test

on:
workflow_dispatch:

jobs:
sanity-test:
strategy:
fail-fast: false
matrix:
runson: [ubuntu-latest, macos-latest, windows-latest]
uses: ./.github/workflows/actions-sync-e2e-test-called.yml
with:
runson: ${{ matrix.runson }}
secrets:
ghes_url: ${{ secrets.sanity_test_ghes_url }}
actions_sync_releasedatetime: ${{ secrets.sanity_test_releasedatetime }}
site_admin_token: ${{ secrets.sanity_test_site_admin_token }}

40 changes: 40 additions & 0 deletions docs/RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Release process

When we want to do a new release, push a git tag with format `v**` and workflow `releases.yml` executes.

This workflow internally uses [go-releaser](https://goreleaser.com/ci/actions/) to push a new release.

Please follow the below detailed steps.
- Create a tag in format `v202205240715`
```code
git tag -a `date "+v%Y%m%d%H%M"` -m "Release a new version"
```
- Get the tag name
```code
git tag
```
- Push the newly created tag
```code
git push origin <tag>
```
- Check workflow `releases.yml` should trigger
- Once completed, go to repo releases page and edit the newly created release as `pre-release`, so we can do sanity testig before we officicaly release
- Recommend to do basic sanity testing (see below) on the new release.
- Once sanity testing is done, we can edit the releas and mark it as `Latest version` and edit the release notes.

## Basic Sanity testing

### Prerequisite

1. Access to a GHES test server
1. Create a PAT token with `site-admin` scope in the GHES environment for `ghe-admin`

### Execution

1. Update below Repository level secrets:

- sanity_test_site_admin_token: The PAT generated earlier
- sanity_test_ghes_url: The URL to the GHES instance
- sanity_test_releasedatetime: The datetime string for the release to test without the `v` (e.g. `202211070205`)

1. Manually trigger this workflow: https://github.com/actions/actions-sync/actions/workflows/actions-sync-e2e-test-caller.yml
17 changes: 17 additions & 0 deletions script/bootstrap-sanity-test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Determine file to download based on current OS
if($IsLinux) {
$file_postfix = "linux_amd64"
} elseif ($IsWindows) {
$file_postfix = "windows_amd64"
} elseif ($IsMacOS) {
$file_postfix = "darwin_amd64"
}

# Download release to test
curl -OL "https://github.com/actions/actions-sync/releases/download/v$Env:RELEASEDATE/gh_$Env:RELEASEDATE`_$file_postfix.tar.gz"

# extract
tar -xvzf "gh_$Env:RELEASEDATE`_$file_postfix.tar.gz"

# prepare cache directory
mkdir -p cache
23 changes: 23 additions & 0 deletions script/execute-sanity-test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Testing Pull Single Repo
echo "`n#########################`n### Testing Pull Single Repo`n#########################"
bin/actions-sync pull --cache-dir "cache" --repo-name "actions/setup-node"

# Testing Sync Single Repo
echo "`n#########################`n### Testing Sync Single Repo`n#########################"
bin/actions-sync sync --cache-dir "cache" --destination-token $Env:TOKEN --destination-url $Env:TEST_INSTANCE_URL --repo-name "actions/setup-node" --actions-admin-user actions-admin

# Testing Pull Multiple Repos
echo "`n#########################`n### Testing Pull Multiple Repos`n#########################"
bin/actions-sync pull --cache-dir "cache" --repo-name-list "actions/setup-node,actions/checkout"

# Testing Push Multiple Existing Repos
echo "`n#########################`n### Testing Push Multiple Existing Repos`n#########################"
bin/actions-sync push --cache-dir "cache" --destination-token $Env:TOKEN --destination-url $Env:TEST_INSTANCE_URL --repo-name-list "actions/setup-node,actions/checkout" --actions-admin-user actions-admin

# Testing Sync Multiple Existing Repos
echo "`n#########################`n### Testing Sync Multiple Existing Repos`n#########################"
bin/actions-sync sync --cache-dir "cache" --destination-token $Env:TOKEN --destination-url $Env:TEST_INSTANCE_URL --repo-name-list "actions/setup-node,actions/checkout" --actions-admin-user actions-admin

# Testing Sync New Single Repo
echo "`n#########################`n### Testing Sync New Single Repo`n#########################"
bin/actions-sync sync --cache-dir "cache" --destination-token $Env:TOKEN --destination-url $Env:TEST_INSTANCE_URL --repo-name-list "actions/actions-sync" --actions-admin-user actions-admin

0 comments on commit 8decd6c

Please sign in to comment.