Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .build/pre_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import os
import shutil
import json
import pkg_resources
from importlib import metadata
from pathlib import Path
import configparser

Expand Down Expand Up @@ -67,7 +67,7 @@ def bundle_feature_flag_config():
def pkg_meta():
pkg_meta_path = Path('user_sync', 'resources', 'pkg_meta.json')
with open(pkg_meta_path, 'w') as f:
json.dump({p.project_name: p.version for p in pkg_resources.working_set}, f)
json.dump({d.metadata['Name']: d.version for d in metadata.distributions()}, f)


if __name__ == '__main__':
Expand Down
25 changes: 12 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@ jobs:

runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest]
os: [ubuntu-24.04, windows-latest]
extension_support: [0, 1]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v2
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.9'
- name: Ubuntu
if: matrix.os == 'ubuntu-20.04'
run: |
python-version: '3.12'
- name: Ubuntu dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo apt-get install -y build-essential
sudo apt-get install -y python3-dev python3-pip python3-virtualenv
sudo apt-get install -y pkg-config libssl-dev libdbus-1-dev libdbus-glib-1-dev python-dbus libffi-dev libkrb5-dev
sudo apt-get install -y build-essential pkg-config \
libssl-dev libdbus-1-dev libdbus-glib-1-dev libffi-dev libkrb5-dev

- name: Install dependencies
run: |
Expand Down
159 changes: 53 additions & 106 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,36 @@ on:
- 'v*'

jobs:
ubuntu-jammy:
runs-on: ubuntu-22.04
ubuntu:
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: [ubuntu-22.04, ubuntu-24.04]
extension_support: [0, 1]
include:
- runner: ubuntu-22.04
label: ubuntu-jammy
asset_label: ubuntu_jammy
- runner: ubuntu-24.04
label: ubuntu-noble
asset_label: ubuntu_noble
- extension_support: 0
variant_tag: "-noext"
- extension_support: 1
variant_tag: ""
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Get version tag
id: get_version
uses: battila7/get-version-action@v2
- name: Ubuntu dependencies
run: |
sudo apt update
sudo apt-get install -y software-properties-common \
build-essential \
python3-dev python3-pip python3.11-venv \
pkg-config libssl-dev libdbus-1-dev libdbus-glib-1-dev libffi-dev libkrb5-dev
sudo apt-get update
sudo apt-get install -y build-essential pkg-config \
libssl-dev libdbus-1-dev libdbus-glib-1-dev libffi-dev libkrb5-dev
- name: Build the executable
run: |
python3 -m venv venv
source venv/bin/activate
pip install ./sign_client
pip install external/okta-0.0.3.1-py2.py3-none-any.whl
pip install -e .
Expand All @@ -46,66 +47,18 @@ jobs:
- name: Get build
run: |
cd dist
tar czf "user-sync-${UST_VERSION}${UST_VARIANT_TAG}-ubuntu_jammy.tar.gz" user-sync
tar czf "user-sync-${UST_VERSION}${UST_VARIANT_TAG}-${ASSET_LABEL}.tar.gz" user-sync
env:
UST_VARIANT_TAG: ${{matrix.variant_tag}}
UST_VERSION: ${{ steps.get_version.outputs.version }}
UST_VERSION: ${{ github.ref_name }}
ASSET_LABEL: ${{ matrix.asset_label }}
- name: Make artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: "ubuntu-jammy${{matrix.variant_tag}}"
name: "${{matrix.label}}${{matrix.variant_tag}}"
path: dist/*.tar.gz
retention-days: 30

ubuntu-focal:
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- extension_support: 0
variant_tag: "-noext"
- extension_support: 1
variant_tag: ""
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Get version tag
id: get_version
uses: battila7/get-version-action@v2
- name: Ubuntu-Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo apt-get install -y build-essential
sudo apt-get install -y python3-dev python3-pip python3-virtualenv
sudo apt-get install -y pkg-config libssl-dev libdbus-1-dev libdbus-glib-1-dev python-dbus libffi-dev libkrb5-dev
- run: |
pip install ./sign_client
pip install external/okta-0.0.3.1-py2.py3-none-any.whl
pip install -e .
pip install -e .[test]
pip install -e .[setup]
- name: Build executable
run: make
env:
UST_EXTENSION: ${{matrix.extension_support}}
- name: Get build
run: |
cd dist
tar czf "user-sync-${UST_VERSION}${UST_VARIANT_TAG}-ubuntu_focal.tar.gz" user-sync
env:
UST_VARIANT_TAG: ${{matrix.variant_tag}}
UST_VERSION: ${{ steps.get_version.outputs.version }}
- name: Make artifacts
uses: actions/upload-artifact@v4
with:
name: "ubuntu-focal${{matrix.variant_tag}}"
path: dist/*.tar.gz
retention-days: 30

windows:
runs-on: windows-latest
strategy:
Expand All @@ -116,13 +69,10 @@ jobs:
- extension_support: 1
variant_tag: ""
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Get version tag
id: get_version
uses: battila7/get-version-action@v2
- run: |
pip install ./sign_client
pip install external/okta-0.0.3.1-py2.py3-none-any.whl
Expand All @@ -135,9 +85,9 @@ jobs:
- name: Get build
run: |
cd dist
7z a user-sync-${{ steps.get_version.outputs.version }}${{matrix.variant_tag}}-win64.zip user-sync.exe
7z a user-sync-${{ github.ref_name }}${{matrix.variant_tag}}-win64.zip user-sync.exe
- name: Make artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: "windows${{matrix.variant_tag}}"
path: dist/*.zip
Expand Down Expand Up @@ -170,10 +120,7 @@ jobs:
extension_support: 1
variant_tag: ""
steps:
- uses: actions/checkout@v4
- name: Get version tag
id: get_version
uses: battila7/get-version-action@v2
- uses: actions/checkout@v7
- name: Update yum dependencies
run: yum update -y
- name: Rocky 8 dependencies
Expand Down Expand Up @@ -217,10 +164,10 @@ jobs:
tar czf "user-sync-${UST_VERSION}${UST_VARIANT_TAG}-${LABEL}.tar.gz" user-sync
env:
UST_VARIANT_TAG: ${{matrix.variant_tag}}
UST_VERSION: ${{ steps.get_version.outputs.version }}
UST_VERSION: ${{ github.ref_name }}
CONTAINER: ${{ matrix.container }}
- name: Make artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: "${{matrix.label}}${{matrix.variant_tag}}"
path: dist/*.tar.gz
Expand All @@ -229,52 +176,52 @@ jobs:
examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: user-sync-examples-zip
run: |
cd examples
zip -r user-sync-examples.zip .
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: examples
path: examples/*.zip
retention-days: 30
- name: user-sync.tar.gz
run: |
tar -czvf "user-sync-examples.tar.gz" examples
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: examples-tar
path: user-sync-examples.tar.gz
retention-days: 30

release:
runs-on: ubuntu-latest
needs: [rocky, ubuntu-jammy, ubuntu-focal, examples, windows]
needs: [rocky, ubuntu, examples, windows]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
path: artifacts
- name: Create release and upload assets
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ github.ref }}
release_name: User Sync Tool ${{ github.ref }}
tag_name: ${{ github.ref_name }}
name: User Sync Tool ${{ github.ref_name }}
body_path: .changelog/latest.md
draft: false
prerelease: false

upload-assets:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
- name: Get version tag
id: get_version
uses: battila7/get-version-action@v2
- uses: AButler/upload-release-assets@v2.0
with:
files: 'examples/*;examples-tar/*;ubuntu-jammy/*;ubuntu-jammy-noext/*;ubuntu-focal/*;ubuntu-focal-noext/*;rocky8/*;rocky8-noext/*;rocky9/*;rocky9-noext/*'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ steps.get_version.outputs.version }}
# Windows builds are intentionally excluded; they're signed and uploaded by an internal build server
files: |
artifacts/examples/*
artifacts/examples-tar/*
artifacts/ubuntu-jammy/*
artifacts/ubuntu-jammy-noext/*
artifacts/ubuntu-noble/*
artifacts/ubuntu-noble-noext/*
artifacts/rocky8/*
artifacts/rocky8-noext/*
artifacts/rocky9/*
artifacts/rocky9-noext/*
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ output_filename = user-sync
prebuilt_dir = external

ifeq ($(OS),Windows_NT)
rm_path := $(shell python -c "import distutils.spawn; print(distutils.spawn.find_executable('rm'))")
rm_path := $(shell python -c "import shutil; print(shutil.which('rm'))")
ifeq ($(rm_path),None)
RM := rmdir /S /Q
else
Expand Down
11 changes: 3 additions & 8 deletions tests/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import os
import sys
import pytest
import pkg_resources
from user_sync import resource


Expand All @@ -45,7 +44,7 @@ def test_resource_file_package(resource_file, tmpdir, monkeypatch):
tmpdir = str(tmpdir)
with monkeypatch.context() as m:
resfile = "test.txt"
m.setattr(pkg_resources, "resource_filename", lambda *args: os.path.join(tmpdir, resfile))
m.setattr(resource, "_package_path", lambda *args: os.path.join(tmpdir, resfile))
assert resource_file(tmpdir, resfile) == resource.get_resource(resfile)


Expand All @@ -68,7 +67,7 @@ def test_resource_invalid_file_package(tmpdir, monkeypatch):
"""test for non-existent resource file in a package"""
tmpdir = str(tmpdir)
with monkeypatch.context() as m:
m.setattr(pkg_resources, "resource_filename", lambda *args: os.path.join('invalid', 'file', 'path'))
m.setattr(resource, "_package_path", lambda *args: os.path.join('invalid', 'file', 'path'))
resfile = os.path.join('invalid', 'file', 'path')
assert resource.get_resource(resfile) is None

Expand Down Expand Up @@ -101,14 +100,10 @@ def test_resource_dir_package(resource_file, tmpdir, monkeypatch):
test_dir = os.path.join(tmpdir, "test")
os.mkdir(test_dir)

m.setattr(pkg_resources, "resource_filename", lambda *args: os.path.join(tmpdir, test_dir))
m.setattr(resource, "_package_path", lambda *args: test_dir)

resfile = "test_{}.txt"

res_test_files = [resfile.format(n + 1) for n in range(3)]

m.setattr(pkg_resources, "resource_listdir", lambda *args: res_test_files)

res_paths = [resource_file(test_dir, resfile.format(n + 1)) for n in range(3)]

assert sorted(res_paths) == sorted(resource.get_resource_dir('test'))
Expand Down
2 changes: 1 addition & 1 deletion user-sync.spec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ a = Analysis(['user_sync/app.py'],
('user_sync/resources/shell_scripts/win', 'resources/shell_scripts/win'),
('user_sync/resources/shell_scripts/linux', 'resources/shell_scripts/linux'),
],
hiddenimports=['win32timezone', 'pkg_resources.py2_warn', 'keyring'],
hiddenimports=['win32timezone', 'keyring'],
hookspath=['.build'],
runtime_hooks=[],
excludes=[],
Expand Down
Loading