Skip to content

Commit

Permalink
Merge branch 'master' into better-agama-derive
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jul 31, 2023
2 parents a0b7061 + 93aaa88 commit fb4b997
Show file tree
Hide file tree
Showing 27 changed files with 753 additions and 649 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/weblate-merge-po.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Weblate Merge PO

on:
schedule:
# run every Monday at 2:42AM UTC
- cron: "42 2 * * 0"

# allow running manually
workflow_dispatch:

jobs:
merge-po:
# allow pushing and creating pull requests
permissions:
contents: write
pull-requests: write

# do not run in forks
if: github.repository == 'openSUSE/agama'

runs-on: ubuntu-latest

container:
image: registry.opensuse.org/opensuse/tumbleweed:latest

steps:
- name: Configure and refresh repositories
run: |
# install the GitHub command line tool "gh"
zypper addrepo https://cli.github.com/packages/rpm/gh-cli.repo
# disable unused repositories to have a faster refresh
zypper modifyrepo -d repo-non-oss repo-openh264 repo-update && \
zypper --non-interactive --gpg-auto-import-keys ref
- name: Install tools
run: zypper --non-interactive install --no-recommends gh git gettext-tools

- name: Configure Git
run: |
git config --global user.name "YaST Bot"
git config --global user.email "[email protected]"
- name: Checkout sources
uses: actions/checkout@v3
with:
path: agama

- name: Checkout Agama-weblate sources
uses: actions/checkout@v3
with:
path: agama-weblate
repository: openSUSE/agama-weblate

- name: Update PO files
working-directory: ./agama
run: |
mkdir -p web/po
# delete the current translations
find web/po -name '*.po' -exec git rm '{}' ';'
# copy the new ones
cp -a ../agama-weblate/web/*.po web/po
git add web/po/*.po
- name: Validate the PO files
working-directory: ./agama
run: msgfmt --check-format -o /dev/null web/po/*.po

# any changes besides the timestamps in the PO files?
- name: Check changes
id: check_changes
working-directory: ./agama
run: |
git diff --staged --ignore-matching-lines="POT-Creation-Date:" \
--ignore-matching-lines="PO-Revision-Date:" web/po > po.diff
if [ -s po.diff ]; then
echo "PO files updated"
# this is an Output Parameter
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
echo "po_updated=true" >> $GITHUB_OUTPUT
else
echo "PO files unchanged"
echo "po_updated=false" >> $GITHUB_OUTPUT
fi
rm po.diff
- name: Push updated PO files
# run only when a PO file has been updated
if: steps.check_changes.outputs.po_updated == 'true'
working-directory: ./agama
run: |
# use a unique branch to avoid possible conflicts with already existing branches
git checkout -b "po_merge_${GITHUB_RUN_ID}"
git commit -a -m "Update PO files"$'\n\n'"Agama-weblate commit: `git -C ../agama-weblate rev-parse HEAD`"
git push origin "po_merge_${GITHUB_RUN_ID}"
- name: Create pull request
# run only when a PO file has been updated
if: steps.check_changes.outputs.po_updated == 'true'
working-directory: ./agama
run: |
gh pr create -B master -H "po_merge_${GITHUB_RUN_ID}" \
--label translations --label bot \
--title "Update PO files" \
--body "Updating the translation files from the agama-weblate repository"
env:
GH_TOKEN: ${{ github.token }}
88 changes: 88 additions & 0 deletions .github/workflows/weblate-update-pot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Weblate Update POT

on:
schedule:
# run every working day (Monday-Friday) at 1:42AM UTC
- cron: "42 1 * * 0-4"

# allow running manually
workflow_dispatch:

jobs:
update-pot:
# do not run in forks
if: github.repository == 'openSUSE/agama'

runs-on: ubuntu-latest

container:
image: registry.opensuse.org/opensuse/tumbleweed:latest

steps:
- name: Configure and refresh repositories
# disable unused repositories to have a faster refresh
run: zypper modifyrepo -d repo-non-oss repo-openh264 repo-update && zypper ref

- name: Install tools
run: zypper --non-interactive install --no-recommends diffutils git gettext-tools

- name: Checkout Agama sources
uses: actions/checkout@v3
with:
path: agama

- name: Generate POT file
# TODO: use a shared script for this
run: |
cd agama/web
xgettext --default-domain=agama --output=- --language=C --keyword= \
--keyword=_:1,1t --keyword=_:1c,2,2t --keyword=C_:1c,2 \
--keyword=N_ --keyword=NC_:1c,2 --foreign-user \
--copyright-holder="SuSE Linux Products GmbH, Nuernberg" \
--from-code=UTF-8 --add-comments=TRANSLATORS --sort-by-file \
$(find . ! -name cockpit.js -name '*.js' -o ! -name '*.test.jsx' -name '*.jsx') | \
sed '/^#/ s/, c-format//' > agama.pot
msgfmt --statistics agama.pot
- name: Validate the generated POT file
run: msgfmt --check-format agama/web/agama.pot

- name: Checkout Weblate sources
uses: actions/checkout@v3
with:
path: agama-weblate
repository: openSUSE/agama-weblate
token: ${{ secrets.GH_TOKEN }}

- name: Configure Git
run: |
git config --global user.name "YaST Bot"
git config --global user.email "[email protected]"
- name: Update POT file
run: |
mkdir -p agama-weblate/web
cp agama/web/agama.pot agama-weblate/web/agama.pot
# any change besides the timestamp in the POT file?
- name: Check changes
id: check_changes
run: |
git -C agama-weblate diff --ignore-matching-lines="POT-Creation-Date:" web/agama.pot > pot.diff
if [ -s pot.diff ]; then
echo "POT file updated"
echo "pot_updated=true" >> $GITHUB_OUTPUT
else
echo "POT file unchanged"
echo "pot_updated=false" >> $GITHUB_OUTPUT
fi
- name: Push updated POT file
# run only when the POT file has been updated
if: steps.check_changes.outputs.pot_updated == 'true'
run: |
cd agama-weblate
git add web/agama.pot
git commit -m "Update POT file"$'\n\n'"Agama commit: $GITHUB_SHA"
git push
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
**Checks**

[![CI Status](https://github.com/openSUSE/agama/actions/workflows/ci.yml/badge.svg)](https://github.com/openSUSE/agama/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/openSUSE/agama/badge.svg?branch=master)](https://coveralls.io/github/openSUSE/agama?branch=master)
[![GitHub Pages](https://github.com/openSUSE/agama/actions/workflows/github-pages.yml/badge.svg)](https://github.com/openSUSE/agama/actions/workflows/github-pages.yml)

**Translations**

[![Weblate Update POT](https://github.com/openSUSE/agama/actions/workflows/weblate-update-pot.yml/badge.svg)](https://github.com/openSUSE/agama/actions/workflows/weblate-update-pot.yml)
[![Weblate Merge PO](https://github.com/openSUSE/agama/actions/workflows/weblate-merge-po.yml/badge.svg)](https://github.com/openSUSE/agama/actions/workflows/weblate-merge-po.yml)
[![Translation Status](https://l10n.opensuse.org/widgets/agama/-/agama-web/svg-badge.svg)](https://l10n.opensuse.org/engage/agama/)

**[OBS systemsmanagement:Agama:Staging](https://build.opensuse.org/project/show/systemsmanagement:Agama:Staging)**

[![Submit agama-cli](https://github.com/openSUSE/agama/actions/workflows/obs-staging-rust.yml/badge.svg)](https://github.com/openSUSE/agama/actions/workflows/obs-staging-rust.yml)
Expand Down
3 changes: 3 additions & 0 deletions doc/answers_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
answers:
- class: storage.luks_activation
answer: "skip"
9 changes: 6 additions & 3 deletions doc/dbus/bus/org.opensuse.Agama.Questions1.bus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@
<method name="Delete">
<arg name="question" type="o" direction="in"/>
</method>
<method name="AddAnswerFile">
<arg name="path" type="s" direction="in"/>
</method>
<!--
sets questions to be answered by default answer instead of asking user
property that defines if questions is interactive or automatically answered with
default answer
-->
<method name="UseDefaultAnswer">
</method>
<property name="Interactive" type="b" access="readwrite"/>
</interface>
</node>
26 changes: 19 additions & 7 deletions doc/dbus/org.opensuse.Agama.Questions1.doc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,30 @@ when the question is answered and the answer is successfully read.
<arg name="data" direction="in" type="a{ss}"/>
<arg direction="out" type="o"/>
</method>
<!--
Delete:
@question: object path of question that should be deleted.
Deletes question. Useful when question is answered and service that asks
already read answer. Usually called by the one that previously created it.
-->
<method name="Delete">
<arg name="question" direction="in" type="o"/>
<arg name="question" type="o" direction="in"/>
</method>

<!--
UseDefaultAnswer:
AddAnswerFile:
@path: Local fs path to answers file in yaml format.
Switches questions to be automatically answered by default answer.
After this method call each follow up question is immediatelly answered.
Useful for doing non interactive installation.
Adds file with list of predefined answers that will be used to
automatically answer matching questions.
-->
<method name="UseDefaultAnswer">
<method name="AddAnswerFile">
<arg name="path" type="s" direction="in"/>
</method>
<!--
property that defines if questions is interactive or automatically answered with
default answer
-->
<property name="Interactive" type="b" access="readwrite"/>
</interface>
</node>
11 changes: 11 additions & 0 deletions doc/questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,14 @@ Sensitive answers or params will be replaced, so the user has to explicitly spec
default answer instead of asking user.
4. I have my own vendor iso and want to pre-configure installer using CLI before showing web UI. And some actions can/will
questions that I want to answer before user sees UI -> Use answers.yml file

### Question Types

| class | description | possible answers | available data | notes |
|--- |--- |--- |--- |--- |
| `software.medium_error` | When there is issue with access to medium | `Retry` `Skip` | `url` with url where failed access happen | |
| `software.unsigned_file` | When file from repository is not digitally signed. If it should be used | `Yes` `No` | `filename` with name of file | |
| `software.import_gpg` | When signature is sign with unknown GPG key | `Trust` `Skip` | `id` of key `name` of key and `fingerprint` of key | |
| `storage.activate_multipath` | When it looks like system has multipath and if it should be activated | `yes` `no` | | Here it is used lower case. It should be unified. |
| `storage.commit_error` | When some storage actions failed and if it should continue | `yes` `no` | | Also here it is lowercase |
| `storage.luks_activation` | When LUKS encrypted device is detected and it needs password to probe it | `skip` `decrypt` | `device` name, `label` of device, `size` of device and `attempt` the number of attempt | Answer contain additional field password that has to be filled if answer is `decrypt`. Attempt data can be used to limit passing wrong password. |
34 changes: 29 additions & 5 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fb4b997

Please sign in to comment.