diff --git a/.github/workflows/configure_osc.sh b/.github/workflows/configure_osc.sh new file mode 100755 index 0000000000..193164b463 --- /dev/null +++ b/.github/workflows/configure_osc.sh @@ -0,0 +1,15 @@ +#! /bin/bash + +# This helper script creates the "osc" configuration file with OBS credentials + +CONFIG_FILE="$HOME/.config/osc/oscrc" + +# do not overwrite the existing config accidentally +if [ -e "$CONFIG_FILE" ]; then + echo "ERROR: $CONFIG_FILE already exists" + exit 1 +fi + +TEMPLATE=$(dirname "${BASH_SOURCE[0]}")/oscrc.template +mkdir -p $(dirname "$CONFIG_FILE") +sed -e "s/@OBS_USER@/$OBS_USER/g" -e "s/@OBS_PASSWORD@/$OBS_PASSWORD/g" "$TEMPLATE" > "$CONFIG_FILE" diff --git a/.github/workflows/obs-staging-playwright.yml b/.github/workflows/obs-staging-playwright.yml new file mode 100644 index 0000000000..df512db08a --- /dev/null +++ b/.github/workflows/obs-staging-playwright.yml @@ -0,0 +1,18 @@ +name: OBS:Staging (cockpit-agama-playwright) + +on: + # runs on pushes targeting the default branch + push: + branches: + - master + paths: + # run only when a Playwright source is changed + - playwright/** + +jobs: + update_staging: + uses: ./.github/workflows/obs-staging-shared.yml + # pass all secrets + secrets: inherit + with: + package_name: cockpit-agama-playwright diff --git a/.github/workflows/obs-staging-rust.yml b/.github/workflows/obs-staging-rust.yml new file mode 100644 index 0000000000..4ef178612d --- /dev/null +++ b/.github/workflows/obs-staging-rust.yml @@ -0,0 +1,19 @@ +name: OBS:Staging (agama-cli) + +on: + # runs on pushes targeting the default branch + push: + branches: + - master + paths: + # run only when a Rust source is changed + - rust/** + +jobs: + update_staging: + uses: ./.github/workflows/obs-staging-shared.yml + # pass all secrets + secrets: inherit + with: + install_packages: obs-service-cargo_audit obs-service-cargo_vendor + package_name: agama-cli diff --git a/.github/workflows/obs-staging-service.yml b/.github/workflows/obs-staging-service.yml new file mode 100644 index 0000000000..c2b39e219a --- /dev/null +++ b/.github/workflows/obs-staging-service.yml @@ -0,0 +1,58 @@ +name: OBS:Staging (rubygem-agama) + +on: + # runs on pushes targeting the default branch + push: + branches: + - master + paths: + # run only when a service source is changed + - service/** + +jobs: + update_staging: + # 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 + git + obs-service-format_spec_file + osc + ruby + 'rubygem(gem2rpm)' + 'rubygem(yast-rake)' + + - name: Git Checkout + uses: actions/checkout@v3 + with: + # fetch all history, we need to find the latest tag and offset for the version number + fetch-depth: 0 + + - name: Fix file owner + # workaround for a strict git check + run: chown -R -c 0 . + + - name: Configure osc + run: .github/workflows/configure_osc.sh + env: + OBS_USER: ${{ secrets.OBS_USER }} + OBS_PASSWORD: ${{ secrets.OBS_PASSWORD }} + + - name: Commit the rubygem-agama package + run: rake osc:commit + working-directory: ./service + env: + # do not build the package with "osc", it takes long time + # and does not provide much value + SKIP_OSC_BUILD: 1 diff --git a/.github/workflows/obs-staging-shared.yml b/.github/workflows/obs-staging-shared.yml new file mode 100644 index 0000000000..cd42f63f0e --- /dev/null +++ b/.github/workflows/obs-staging-shared.yml @@ -0,0 +1,71 @@ +# this is a shared workflow, not called as a top level workflow + +name: Update OBS Staging + +on: + workflow_call: + secrets: + OBS_USER: + required: true + OBS_PASSWORD: + required: true + + inputs: + install_packages: + description: Additional packages to install + required: false + type: string + + package_name: + description: OBS package name + required: true + type: string + +jobs: + update_staging_package: + # do not run in forks + if: github.repository == 'openSUSE/agama' + + runs-on: ubuntu-latest + + container: + image: registry.opensuse.org/opensuse/tumbleweed:latest + + steps: + - name: Git Checkout + uses: actions/checkout@v3 + + - 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 + cpio + obs-service-download_files + obs-service-format_spec_file + obs-service-obs_scm + osc + ${{ inputs.install_packages }} + + - name: Configure osc + run: .github/workflows/configure_osc.sh + env: + OBS_USER: ${{ secrets.OBS_USER }} + OBS_PASSWORD: ${{ secrets.OBS_PASSWORD }} + + - name: Checkout ${{ inputs.package_name }} + run: osc co systemsmanagement:Agama:Staging ${{ inputs.package_name }} + + - name: Run services + run: osc service manualrun + working-directory: ./systemsmanagement:Agama:Staging/${{ inputs.package_name }} + + - name: Check status + run: osc status + working-directory: ./systemsmanagement:Agama:Staging/${{ inputs.package_name }} + + - name: Commit ${{ inputs.package_name }} + run: |- + osc commit -m "Updated to $(sed -e '/^version:/!d' -e 's/version: *\(.*\)/\1/' agama.obsinfo) ($(sed -e '/^commit:/!d' -e 's/commit: *\(.*\)/\1/' agama.obsinfo))" + working-directory: ./systemsmanagement:Agama:Staging/${{ inputs.package_name }} diff --git a/.github/workflows/obs-staging-web.yml b/.github/workflows/obs-staging-web.yml new file mode 100644 index 0000000000..e795e70310 --- /dev/null +++ b/.github/workflows/obs-staging-web.yml @@ -0,0 +1,19 @@ +name: OBS:Staging (cockpit-agama) + +on: + # runs on pushes targeting the default branch + push: + branches: + - master + paths: + # run only when a web frontend source is changed + - web/** + +jobs: + update_staging: + uses: ./.github/workflows/obs-staging-shared.yml + # pass all secrets + secrets: inherit + with: + install_packages: obs-service-node_modules + package_name: cockpit-agama diff --git a/.github/workflows/oscrc.template b/.github/workflows/oscrc.template new file mode 100644 index 0000000000..e6133a0677 --- /dev/null +++ b/.github/workflows/oscrc.template @@ -0,0 +1,7 @@ +[general] +apiurl = https://api.opensuse.org + +[https://api.opensuse.org] +user=@OBS_USER@ +pass=@OBS_PASSWORD@ +credentials_mgr_class=osc.credentials.PlaintextConfigFileCredentialsManager diff --git a/README.md b/README.md index 1dde91cd16..ceb4b3c77e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ [![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) +**[OBS systemsmanagement:Agama:Staging](https://build.opensuse.org/project/show/systemsmanagement:Agama:Staging)** + +[![OBS Staging (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) +[![OBS:Staging (cockpit-agama)](https://github.com/openSUSE/agama/actions/workflows/obs-staging-web.yml/badge.svg)](https://github.com/openSUSE/agama/actions/workflows/obs-staging-web.yml) +[![OBS:Staging (rubygem-agama)](https://github.com/openSUSE/agama/actions/workflows/obs-staging-service.yml/badge.svg)](https://github.com/openSUSE/agama/actions/workflows/obs-staging-service.yml) +[![OBS:Staging (cockpit-agama-playwright)](https://github.com/openSUSE/agama/actions/workflows/obs-staging-playwright.yml/badge.svg)](https://github.com/openSUSE/agama/actions/workflows/obs-staging-playwright.yml) + # Agama: A Service-based Linux Installer Agama is a new Linux installer born in the core of the YaST team. It is designed to offer re-usability, integration with third party tools and the possibility of building advanced user interfaces over it. diff --git a/Rakefile b/Rakefile index f8e358c1f0..f2fdef496e 100644 --- a/Rakefile +++ b/Rakefile @@ -74,8 +74,11 @@ end # Removes the "package" task to redefine it later. Rake::Task["package"].clear + # Disables the osc:build -# Rake::Task["osc:build"].clear +if ENV["SKIP_OSC_BUILD"] == "1" + Rake::Task["osc:build"].clear +end # TODO: redefine :tarball instead of :package desc "Prepare sources for rpm build" @@ -87,7 +90,7 @@ task package: [] do sh "gem build #{name}.gemspec" gem = find_gem(dir).first gem2rpm = File.join(package_dir, "gem2rpm.yml") - sh "gem2rpm --config #{gem2rpm} --template opensuse #{gem} > package/#{package_name}.spec" + sh "gem2rpm --local --config #{gem2rpm} --template opensuse #{gem} > package/#{package_name}.spec" FileUtils.mv(gem, package_dir) end end diff --git a/doc/obs_integration.md b/doc/obs_integration.md new file mode 100644 index 0000000000..31b76e5501 --- /dev/null +++ b/doc/obs_integration.md @@ -0,0 +1,82 @@ +# The Open Build Service (OBS) Integration + +The Agama installer packages are built in the openSUSE [Open Build Service]( +https://build.opensuse.org/). + +## Staging Project + +The [systemsmanagement:Agama:Staging](https://build.opensuse.org/project/show/systemsmanagement:Agama:Staging) +contains the latest packages built from the `master` Git branch. This project +contains unstable development version of Agama. It is intended for development +and testing. + +The packages are automatically updated whenever the `master` branch is changed, +see more details below. + +## Development Project + +The [systemsmanagement:Agama:Devel](https://build.opensuse.org/project/show/systemsmanagement:Agama:Devel) +contains the latest released version of the Agama project. The packages should +be more stable than in the Staging project. + +These packages are updated manually when a new version is released. + +## OBS Synchronization + +The automatic OBS synchronization is implemented using the [GitHub Actions]( +https://github.com/features/actions). The actions are defined in the +`obs-staging-*.yml` files in the [.github/workflows](../.github/workflows) +directory. + +Because the process of updating a package is the same for several packages +the definition is shared in the [obs-staging-shared.yml]( +../.github/workflows/obs-staging-shared.yml) file. + +The packages in staging are updated only when a respective source file is +changed. That saves some resources for rebuilding and makes synchronization +faster. But that also means the packages might not have exactly same version. + +### Details + +The packages in OBS are updated by running the OBS service which downloads the +sources from GitHub and dependencies from other repositories (Rust or NPM +packages). + +The process of updating a package is basically: + +- `osc co systemsmanagement:Agama:Staging ` - checkout the package + from OBS +- `osc service manualrun` - update the sources and dependencies by running + the OBS services locally +- `osc commit` - upload the changes to the OBS server, it will rebuild the + updated package automatically + +To run the services locally you need to install the OSC tool and several +packages with the used OBS services: + +```shell +zypper install osc obs-service-cargo_audit obs-service-cargo_vendor \ + obs-service-download_files obs-service-format_spec_file obs-service-obs_scm \ + obs-service-node_modules +``` + +The `rubygem-agama` package uses a different approach because the Ruby packages +use `*.gem` files which are not supported by OBS services. It uses the +[osc:commit](https://github.com/openSUSE/packaging_rake_tasks#osccommit) Rake +task, same as the YaST packages. + +### Package Versioning + +### Staging + +The packages in the Staging project use a version built from the last released +version with a number of commits in the `master` branch since that release. + +The version is automatically constructed by the OBS service, for the +`rubygem-agama` package the version is built using the `git describe --tags` +command. + +### Devel + +The Devel packages use the release version (a Git tag) without any additional +number of commits. diff --git a/service/.gitignore b/service/.gitignore index e3200e0f81..ec66c82d0a 100644 --- a/service/.gitignore +++ b/service/.gitignore @@ -1,4 +1,6 @@ *.gem +# the spec file is generated +/package/*.spec *.rbc /.config /coverage/ diff --git a/service/VERSION b/service/VERSION deleted file mode 100644 index 879b416e60..0000000000 --- a/service/VERSION +++ /dev/null @@ -1 +0,0 @@ -2.1 diff --git a/service/agama.gemspec b/service/agama.gemspec index d8fe294a7c..844a06cccf 100644 --- a/service/agama.gemspec +++ b/service/agama.gemspec @@ -22,7 +22,9 @@ Gem::Specification.new do |spec| spec.name = "agama" - spec.version = File.read("VERSION").chomp + # the version is .devel + # or just if there are no additional commits + spec.version = `git describe --tags`.chomp.sub(/^v/, "").sub(/-([0-9]+)-g\h+\Z/, ".devel\\1") spec.summary = "Agama Installer Service" spec.description = "System service for Agama, an experimental YaST-based installer." spec.author = "YaST Team"