Improved README and ui-asset workflow
This commit is contained in:
@@ -35,8 +35,8 @@ jobs:
|
|||||||
export PATH=$PATH:$DEPS
|
export PATH=$PATH:$DEPS
|
||||||
|
|
||||||
# Setup git config
|
# Setup git config
|
||||||
git config --global user.email "ui-asset-bot@gchq.icu"
|
git config --global user.email "$BOT_EMAIL"
|
||||||
git config --global user.name "ui-asset-bot"
|
git config --global user.name "$BOT_NAME"
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
# #
|
# #
|
||||||
@@ -66,3 +66,5 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
MODIFIED_FILES: ${{ steps.changed-files.outputs.modified_files }}
|
MODIFIED_FILES: ${{ steps.changed-files.outputs.modified_files }}
|
||||||
GITEA_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }}
|
||||||
|
BOT_NAME: "ui-asset-bot"
|
||||||
|
BOT_EMAIL: "ui-asset-bot@gchq.icu"
|
||||||
|
|||||||
27
README.md
27
README.md
@@ -76,16 +76,19 @@ You will then see a prompt, please fill it out like outlined below:
|
|||||||
```
|
```
|
||||||
|
|
||||||
2. First add your changes to git:
|
2. First add your changes to git:
|
||||||
|
|
||||||
1. `git add <file1> <file2>` your changes
|
1. `git add <file1> <file2>` your changes
|
||||||
2. Execute `nix fmt` to lint your files
|
2. Execute `nix fmt` to lint your files
|
||||||
3. `git commit -a -m "My descriptive commit message"`
|
3. `git commit -a -m "My descriptive commit message"`
|
||||||
4. Make sure your branch has the latest changes from upstream by executing:
|
4. Make sure your branch has the latest changes from upstream by executing:
|
||||||
```bash
|
|
||||||
git fetch && git rebase origin/main --autostash
|
```bash
|
||||||
```
|
git fetch && git rebase origin/main --autostash
|
||||||
5. Execute `git status` to see if you have a merge conflict.
|
```
|
||||||
6. If so edit the file and fix the conflict. Here is a tutorial how to do so in [vscode](https://code.visualstudio.com/docs/sourcecontrol/overview#_merge-conflicts)
|
|
||||||
7. Execute `git merge --continue` and repeat step 5 till there are no conflicts anymore
|
5. Execute `git status` to see if you have a merge conflict.
|
||||||
|
6. If so edit the file and fix the conflict. Here is a tutorial how to do so in [vscode](https://code.visualstudio.com/docs/sourcecontrol/overview#_merge-conflicts)
|
||||||
|
7. Execute `git merge --continue` and repeat step 5 till there are no conflicts anymore
|
||||||
|
|
||||||
3. To automatically open up a pull request, that gets merged if all tests pass execute:
|
3. To automatically open up a pull request, that gets merged if all tests pass execute:
|
||||||
|
|
||||||
@@ -101,3 +104,13 @@ git push origin HEAD:MyUserName-main
|
|||||||
```
|
```
|
||||||
|
|
||||||
to directly push to your open pull request
|
to directly push to your open pull request
|
||||||
|
|
||||||
|
## Using this template
|
||||||
|
|
||||||
|
Setup two new gitea accounts.
|
||||||
|
One named `ui-asset-bot`, generate an access token for it with all access permissions and set under `settings/actions/secrets` a secret called BOT_ACCESS_TOKEN with the token.
|
||||||
|
Also edit the file `.gitea/workflows/ui_assets.yaml` and change the `BOT_EMAIL` variable to the email you set for that account.
|
||||||
|
The second account is called `merge-bot` edit the file `pkgs/merge-after-ci/default.nix`
|
||||||
|
if the name should be different.
|
||||||
|
Then set the main branch to protected and add `merge-bot` to whitelisted users for pushing. Also set an unprotected file pattern to `**/ui-assets.nix`.
|
||||||
|
Add both `ui-asset-bot` and `merge-bot` as collaborators.
|
||||||
|
|||||||
@@ -56,15 +56,15 @@ Add this `launch.json` to your .vscode directory to have working breakpoints in
|
|||||||
|
|
||||||
## Run locally single-threaded for debugging
|
## Run locally single-threaded for debugging
|
||||||
|
|
||||||
By default tests run in parallel using pytest-parallel.
|
By default tests run in parallel using pytest-xdist.
|
||||||
pytest-parallel however breaks `breakpoint()`. To disable it, use this:
|
pytest-xdist however breaks `breakpoint()`. To disable it, use this:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
pytest --workers "" -s
|
pytest -n0 -s
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also run a single test like this:
|
You can also run a single test like this:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
pytest --workers "" -s tests/test_secrets_cli.py::test_users
|
pytest -n0 -s tests/test_secrets_cli.py::test_users
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -3,8 +3,17 @@ set -xeuo pipefail
|
|||||||
|
|
||||||
# GITEA_TOKEN
|
# GITEA_TOKEN
|
||||||
if [[ -z "${GITEA_TOKEN:-}" ]]; then
|
if [[ -z "${GITEA_TOKEN:-}" ]]; then
|
||||||
echo "GITEA_TOKEN is not set"
|
echo "GITEA_TOKEN is not set. Check if the secret BOT_ACCESS_TOKEN is set in the repository settings."
|
||||||
echo "Go to https://gitea.gchq.icu/user/settings/applications and generate a token"
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${BOT_NAME:-}" ]]; then
|
||||||
|
echo "Env var BOT_NAME is not set. Use the name of the bot user here."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${GITHUB_SERVER_URL:-}" ]]; then
|
||||||
|
echo "Env var GITHUB_SERVER_URL is not set. Please use the Gitea base URL here."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -22,11 +31,12 @@ nix build '.#ui' --out-link "$tmpdir/result"
|
|||||||
tar --transform 's,^\.,assets,' -czvf "$tmpdir/assets.tar.gz" -C "$tmpdir"/result/lib/node_modules/*/out .
|
tar --transform 's,^\.,assets,' -czvf "$tmpdir/assets.tar.gz" -C "$tmpdir"/result/lib/node_modules/*/out .
|
||||||
NAR_HASH=$(nix-prefetch-url --unpack file://<(cat "$tmpdir/assets.tar.gz"))
|
NAR_HASH=$(nix-prefetch-url --unpack file://<(cat "$tmpdir/assets.tar.gz"))
|
||||||
|
|
||||||
owner=ui-asset-bot
|
owner=$BOT_NAME
|
||||||
package_name=ui
|
package_name=ui
|
||||||
package_version=$NAR_HASH
|
package_version=$NAR_HASH
|
||||||
|
baseurl=$GITHUB_SERVER_URL
|
||||||
|
|
||||||
url="https://gitea.gchq.icu/api/packages/$owner/generic/$package_name/$package_version/assets.tar.gz"
|
url="$baseurl/api/packages/$owner/generic/$package_name/$package_version/assets.tar.gz"
|
||||||
set +x
|
set +x
|
||||||
curl --upload-file "$tmpdir/assets.tar.gz" -X PUT "$url?token=$GITEA_TOKEN"
|
curl --upload-file "$tmpdir/assets.tar.gz" -X PUT "$url?token=$GITEA_TOKEN"
|
||||||
set -x
|
set -x
|
||||||
|
|||||||
Reference in New Issue
Block a user