Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin_public/main' into release/v0.2rc
Browse files Browse the repository at this point in the history
  • Loading branch information
wwoytenko committed May 8, 2024
2 parents 4d2bdfc + 79ff907 commit a31fd23
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 228 deletions.
36 changes: 27 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,20 +180,38 @@ jobs:
- name: Install dependicies
run: pip install -r requirements.txt

- name: Setup docs deploy
run: |
git config --global user.name "Docs Deployer"
git config --global user.email [email protected]
echo "TAGS=$(git log --tags --simplify-by-decoration --pretty='format:%d' --since=2024-04-30 | sed '/^$/d' | cut -d ':' -f 2 | cut -d ')' -f 1 | tac | tr '\n' ' ')" >> $GITHUB_ENV
- name: Build docs
run: mkdocs build
run: |
for tag in ${{ env.TAGS }}; do
echo "### CHECKOUT TO ${tag} ###"
git checkout $tag
if [[ "$tag" == *"rc"* || "$tag" == *"dev"* || "$tag" == *"pre"* ]]; then
mike deploy $tag
else
mike deploy --update-aliases $tag latest
fi
done
- name: Create docs directory
run: sudo mkdir -p ${{ secrets.DOCS_DEPLOY_DIR }}
- name: Set latest version as default
run: mike set-default latest

- name: Move html files to docs directory
run: sudo mv site ${{ secrets.DOCS_DEPLOY_DIR }}/html-${{ github.ref_name}}
- name: Change branch to get html files
run: git checkout gh-pages

- name: Remove old folder
run: sudo rm -rf ${{ secrets.DOCS_DEPLOY_DIR }}/html

- name: Remove old symlink
run: sudo unlink ${{ secrets.DOCS_DEPLOY_DIR }}/html
- name: Create docs directory
run: sudo mkdir -p ${{ secrets.DOCS_DEPLOY_DIR }}/html

- name: Create new symlink
run: sudo ln -s ${{ secrets.DOCS_DEPLOY_DIR }}/html-${{ github.ref_name}} ${{ secrets.DOCS_DEPLOY_DIR }}/html
- name: Move html files to docs directory
run: sudo cp -r * ${{ secrets.DOCS_DEPLOY_DIR }}/html

- name: Restart web service
run: sudo systemctl restart nginx
154 changes: 0 additions & 154 deletions docs/mkdocs.yml

This file was deleted.

9 changes: 8 additions & 1 deletion docs/overrides/main.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{% extends "base.html" %}

{% block announce %}
Version 0.1.12 is <a href="https://github.com/GreenmaskIO/greenmask/releases/tag/v0.1.11">released</a>
Version 0.1.13 is <a href="https://github.com/GreenmaskIO/greenmask/releases/tag/v0.1.13">released</a>
{% endblock %}

{% block outdated %}
You're not viewing the latest version.
<a href="{{ '../' ~ base_url }}">
<strong>Click here to go to latest.</strong>
</a>
{% endblock %}
12 changes: 12 additions & 0 deletions docs/release_notes/greenmask_0_1_13.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Greenmask 0.1.13

This release introduces only improvements in documentation deployment. The core greenmask utility does not contain any changes.

## Changes

* Added documentation deployment with versioning

## Assets

To download the Greenmask binary compatible with your system, see
the [release's assets list](https://github.com/GreenmaskIO/greenmask/releases/tag/v0.1.13).
138 changes: 77 additions & 61 deletions internal/db/postgres/dumpers/large_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,67 +56,10 @@ func (lod *BlobsDumper) Execute(ctx context.Context, tx pgx.Tx, st storages.Stor
w, r := countwriter.NewGzipPipe()

// Writing goroutine
eg.Go(
func() error {
defer func() {
log.Debug().
Uint32("oid", uint32(lo.Oid)).
Msg("closing reader")
if err := r.Close(); err != nil {
log.Warn().
Err(err).
Uint32("oid", uint32(lo.Oid)).
Msg("error closing LargeObject reader")
}
}()
err := st.PutObject(gtx, fmt.Sprintf("blob_%d.dat.gz", lo.Oid), r)
if err != nil {
return fmt.Errorf("cannot write large object %d object: %w", lo.Oid, err)
}
return nil
},
)
eg.Go(largeObjectWriter(gtx, st, lo, r))

// Dumping goroutine
eg.Go(
func() error {
defer func() {
log.Debug().
Uint32("oid", uint32(lo.Oid)).
Msg("closing writer")
if err := w.Close(); err != nil {
log.Warn().Err(err).Msg("error closing Blobs writer")
}
}()
buf := make([]byte, loBufSize)
los := tx.LargeObjects()
lo, err := los.Open(ctx, uint32(lo.Oid), pgx.LargeObjectModeRead)
defer func() {
if err := lo.Close(); err != nil {
log.Warn().Err(err).Msg("error closing large object")
}
}()
if err != nil {
return fmt.Errorf("error dumping large object %d: %w", lo, err)
}
var done bool
for !done {
size, err := lo.Read(buf)
if err != nil {
if errors.Is(err, io.EOF) {
buf = buf[:size]
done = true
} else {
return fmt.Errorf("error reading large object %d: %w", lo, err)
}
}
if _, err = w.Write(buf); err != nil {
return fmt.Errorf("error writing large object %d into storage: %w", lo, err)
}
}
return nil
},
)
eg.Go(largeObjectDumper(gtx, lo, w, tx))

if err := eg.Wait(); err != nil {
return nil, err
Expand All @@ -130,6 +73,16 @@ func (lod *BlobsDumper) Execute(ctx context.Context, tx pgx.Tx, st storages.Stor
Msg("dumping large object completed")
}

// Writing blobs.toc
if err := lod.generateBlobsToc(ctx, st); err != nil {
return nil, fmt.Errorf("cannot write large object blobs.toc: %w", err)
}

return lod.Blobs, nil
}

func (lod *BlobsDumper) generateBlobsToc(ctx context.Context, st storages.Storager) error {
log.Debug().Msg("writing blobs.toc")
// Writing blobs.toc
blobsTocBuf := bytes.NewBuffer(nil)

Expand All @@ -139,10 +92,73 @@ func (lod *BlobsDumper) Execute(ctx context.Context, tx pgx.Tx, st storages.Stor

err := st.PutObject(ctx, "blobs.toc", blobsTocBuf)
if err != nil {
return nil, fmt.Errorf("cannot write large object blobs.toc: %w", err)
return fmt.Errorf("cannot write large object blobs.toc: %w", err)
}
return nil
}

return lod.Blobs, nil
func largeObjectWriter(ctx context.Context, st storages.Storager, lo *entries.LargeObject, r countwriter.CountReadCloser) func() error {
return func() error {
defer func() {
log.Debug().
Uint32("oid", uint32(lo.Oid)).
Msg("closing reader")
if err := r.Close(); err != nil {
log.Warn().
Err(err).
Uint32("oid", uint32(lo.Oid)).
Msg("error closing LargeObject reader")
}
}()
err := st.PutObject(ctx, fmt.Sprintf("blob_%d.dat.gz", lo.Oid), r)
if err != nil {
return fmt.Errorf("cannot write large object %d object: %w", lo.Oid, err)
}
return nil
}
}

func largeObjectDumper(ctx context.Context, lo *entries.LargeObject, w countwriter.CountWriteCloser, tx pgx.Tx) func() error {
return func() error {
defer func() {
log.Debug().
Uint32("oid", uint32(lo.Oid)).
Msg("closing writer")
if err := w.Close(); err != nil {
log.Warn().Err(err).Msg("error closing Blobs writer")
}
}()
buf := make([]byte, loBufSize)
los := tx.LargeObjects()
loObj, err := los.Open(ctx, uint32(lo.Oid), pgx.LargeObjectModeRead)
if err != nil {
return fmt.Errorf("error opening large object %d: %w", lo.Oid, err)
}
defer func() {
if err := loObj.Close(); err != nil {
log.Warn().Err(err).Msg("error closing large object")
}
}()
if err != nil {
return fmt.Errorf("error dumping large object %d: %w", lo.Oid, err)
}
var done bool
for !done {
size, err := loObj.Read(buf)
if err != nil {
if errors.Is(err, io.EOF) {
buf = buf[:size]
done = true
} else {
return fmt.Errorf("error reading large object %d: %w", lo.Oid, err)
}
}
if _, err = w.Write(buf); err != nil {
return fmt.Errorf("error writing large object %d into storage: %w", lo.Oid, err)
}
}
return nil
}
}

func (lod *BlobsDumper) DebugInfo() string {
Expand Down
Loading

0 comments on commit a31fd23

Please sign in to comment.