Migrate to Github Actions

Closes #206
This commit is contained in:
Josh Holmer 2020-04-15 11:50:46 -04:00
parent 63e36ed43f
commit 43735086d1
12 changed files with 197 additions and 129 deletions

67
.github/workflows/deploy.yml vendored Normal file
View file

@ -0,0 +1,67 @@
name: deploy
on:
push:
tags:
- 'v*.*.*'
jobs:
create-binaries:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable-x86_64-pc-windows-gnu
override: true
- name: Build oxipng
run: |
cargo build --release
- name: Create zip
run: |
$OXIPNG_PATH="$Env:GITHUB_WORKSPACE\target\release"
7z a oxipng.zip "Cargo.lock" "$OXIPNG_PATH\oxipng.exe" "C:\usr\local"
- name: Upload binaries
uses: actions/upload-artifact@v1
with:
name: oxipng-binaries
path: oxipng.zip
deploy:
needs: create-binaries
env:
FILENAME: oxipng-windows-sdk
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Download the zip
uses: actions/download-artifact@v1
with:
name: oxipng-binaries
- name: Unzip oxipng Windows binaries
run: |
unzip oxipng-binaries/oxipng.zip -d oxipng-binaries
mv oxipng-binaries/Cargo.lock .
- name: Handle binaries
run: |
mv oxipng-binaries/local oxipng-binaries/$FILENAME
strip oxipng-binaries/oxipng.exe
- name: Package release binaries
id: data
run: |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2)
echo "::set-output name=version::$VERSION"
cd oxipng-binaries
zip -r oxipng-$VERSION-windows.zip $FILENAME
- name: Create a release
uses: softprops/action-gh-release@v1
with:
name: v${{ steps.data.outputs.version }}
files: |
Cargo.lock
oxipng-binaries/oxipng-${{ steps.data.outputs.version }}-windows.zip
oxipng-binaries/oxipng.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

121
.github/workflows/oxipng.yml vendored Normal file
View file

@ -0,0 +1,121 @@
name: oxipng
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build-test-unix:
runs-on: ubuntu-latest
strategy:
matrix:
conf:
- minimum-stable
- latest-stable
- latest-beta
- latest-nightly
include:
- conf: minimum-stable
toolchain: 1.41.0
- conf: latest-stable
toolchain: stable
- conf: latest-beta
toolchain: beta
- conf: latest-nightly
toolchain: nightly
steps:
- uses: actions/checkout@v1
- name: Install ${{ matrix.toolchain }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
components: clippy, rustfmt
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry/cache
key: ${{ runner.os }}-${{ matrix.conf }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.conf }}-cargo-registry-
- name: Run rustfmt
if: matrix.toolchain == 'stable'
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- name: Run clippy
if: matrix.toolchain == 'stable'
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -- -D warnings
- name: Run tests
run: cargo test
- name: Build benchmarks
if: matrix.toolchain == 'nightly'
run: cargo bench --no-run
- name: Build docs
run: cargo doc --no-deps
- name: Check no default features
if: matrix.toolchain == 'stable'
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --no-default-features -- -D warnings
build-test-windows:
runs-on: windows-latest
strategy:
matrix:
conf:
- minimum-stable
- latest-stable
include:
- conf: minimum-stable
toolchain: 1.41.0
- conf: latest-stable
toolchain: stable
steps:
- uses: actions/checkout@v1
- name: Install ${{ matrix.toolchain }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
components: clippy, rustfmt
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry/cache
key: ${{ runner.os }}-${{ matrix.conf }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.conf }}-cargo-registry-
- name: Run rustfmt
if: matrix.toolchain == 'stable'
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- name: Run clippy
if: matrix.toolchain == 'stable'
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -- -D warnings
- name: Run tests
run: cargo test
- name: Build docs
run: cargo doc --no-deps
- name: Check no default features
if: matrix.toolchain == 'stable'
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --no-default-features -- -D warnings

View file

@ -1,49 +0,0 @@
language: rust
env:
global:
- PROJECT_NAME=oxipng
matrix:
include:
- os: osx
rust: stable
env: TARGET=x86_64-apple-darwin
cache: cargo
- os: linux
rust: 1.41.0
env: TARGET=x86_64-unknown-linux-gnu
cache: cargo
- os: linux
rust: stable
env: TARGET=x86_64-unknown-linux-gnu
cache: cargo
- os: linux
rust: beta
env: TARGET=x86_64-unknown-linux-gnu
cache: cargo
- os: linux
rust: nightly
env: TARGET=x86_64-unknown-linux-gnu
cache: cargo
allow_failures:
- rust: beta
- rust: nightly
deploy:
provider: releases
api_key:
secure: FarU1VnPW15WXkNP76rQH0VdB+dnp6Op7t2/bl5oCjn7OQ8R3vB32vxCP7DXtBvtE2U9z3CeRmE4pKIRN1rObb/GUyNKxPH0UJiTtDgGtxtTYZHdBjED2nEqdcA2+G1ElCub5O3NhtzsRLM1KPPukJcts6gCFgK/tgcDyKLMX/iGsXOuxOwqu6algZOTcHIaT4M8/TjH7g/hzOz8UKoaqZgSLuKLJ+J30LCJKK4umW57Nev66ATavBWQ3MIFCTyBc9YSsMSQcsjtlA7jcHNhelsCxQHzbxXWQK1jF439QXyNHog3tS41qmfMal+TUhW/NiSkqwJ1//PowD+oYI7si/biBawf6PU2oz5AfWknzPr4k6lAX2WYDcRLIkwEwKi5fHrvMYL0TuNWGb8gF+7DD+7DRaZrRLAbrA6SOFGydSPNzO7HvEYJjs39/2LfqXOQ0aie4ez5fGzsE655D+U1ulmVOx3Y6C1rxKi/oBVJZNuvdMPqtRpgbFYtAsk//wM+nt+YH8TndFR+x6AjZ9OTSDbbJwMLm1SckDLAE/sAC/vU+A6io82uMuDvKmPrtiOKsZp4kmwo5N1CWvIBtvd8evIMPAOFW51AncxnCvCiqYGtfB/BkKAr7mcxiwuWVwXMkOpSr7JzfQd8C5gOEMVczA9qnB6fRCY+dpxGjY0LSY0=
file_glob: true
file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.*
# don't delete the artifacts from previous phases
skip_cleanup: true
# deploy when a new tag is pushed
on:
# channel to use to produce the release artifacts
condition: $TRAVIS_RUST_VERSION = stable
tags: true
notifications:
email:
on_success: never

1
Cargo.lock generated
View file

@ -319,7 +319,6 @@ dependencies = [
"num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rgb 0.8.16 (registry+https://github.com/rust-lang/crates.io-index)",
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"wild 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"zopfli 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

View file

@ -1,64 +0,0 @@
environment:
global:
# This will be used as part of the zipfile name
PROJECT_NAME: oxipng
matrix:
# Stable channel
- TARGET: i686-pc-windows-msvc
CHANNEL: stable
- TARGET: x86_64-pc-windows-msvc
CHANNEL: stable
- TARGET: x86_64-pc-windows-msvc
CHANNEL: nightly
# Install Rust and Cargo
# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
install:
- curl -sSf -o rustup-init.exe https://win.rustup.rs
- rustup-init.exe --default-host %TARGET% --default-toolchain %CHANNEL% -y
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- rustc -Vv
- cargo -V
# 'cargo test' takes care of building for us, so disable Appveyor's build stage. This prevents
# the "directory does not contain a project or solution file" error.
# source: https://github.com/starkat99/appveyor-rust/blob/master/appveyor.yml#L113
build: false
# Equivalent to Travis' `script` phase
test_script:
- cargo build
- cargo test %TESTFLAGS%
before_deploy:
# Generate artifacts for release
- SET RUSTFLAGS=-C target-feature=+crt-static
- cargo build --release
- mkdir staging
- copy target\release\oxipng.exe staging
- cd staging
# release zipfile will look like 'rust-everywhere-v1.2.3-x86_64-pc-windows-msvc'
- 7z a ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip *
- appveyor PushArtifact ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip
deploy:
description: 'Windows release'
# All the zipped artifacts will be deployed
artifact: /.*\.zip/
# - Go to 'https://github.com/settings/tokens/new' and generate a Token with only the
# `public_repo` scope enabled
# - Then go to 'https://ci.appveyor.com/tools/encrypt' and enter the newly generated token.
# - Enter the "encrypted value" below
auth_token:
secure: JT77kw2p+U5Z9yM/77QjEWRFgvyaGOO2SquE5OBgUNpqSt4VDg/Mdicy8pkSvSEu
provider: GitHub
# deploy when a new tag is pushed and only on the stable channel
on:
# channel to use to produce the release artifacts
# NOTE make sure you only release *once* per target
CHANNEL: stable
appveyor_repo_tag: true
branches:
only:
- master

View file

@ -1 +0,0 @@
format_strings = false

View file

@ -1,5 +1,5 @@
use crate::{PngError, PngResult};
use crate::atomicmin::AtomicMin;
use crate::{PngError, PngResult};
use libdeflater::{CompressionError, CompressionLvl, Compressor};
pub fn deflate(data: &[u8], max_size: &AtomicMin) -> PngResult<Vec<u8>> {

View file

@ -1,9 +1,9 @@
use indexmap::IndexSet;
use crate::colors::{BitDepth, ColorType};
use crate::error::PngError;
use crate::PngResult;
use byteorder::{BigEndian, ReadBytesExt};
use crc::crc32;
use indexmap::IndexSet;
use std::io::Cursor;
#[derive(Debug, Clone, Copy)]

View file

@ -28,7 +28,7 @@ use crate::png::PngImage;
use crate::reduction::*;
use crc::crc32;
use image::{DynamicImage, GenericImageView, ImageFormat, Pixel};
use indexmap::{IndexSet, IndexMap};
use indexmap::{IndexMap, IndexSet};
use rayon::prelude::*;
use std::fmt;
use std::fs::{copy, File};
@ -583,8 +583,7 @@ fn optimize_png(
eprintln!("Trying: {} combinations", results.len());
}
let filters: IndexMap<u8, Vec<u8>> =
filter
let filters: IndexMap<u8, Vec<u8>> = filter
.par_iter()
.with_max_len(1)
.map(|f| {
@ -866,12 +865,9 @@ fn perform_strip(png: &mut PngData, opts: &Options) {
match opts.strip {
// Strip headers
Headers::None => (),
Headers::Keep(ref hdrs) => {
raw.aux_headers.retain(|hdr, _| {
std::str::from_utf8(hdr)
.map_or(false, |name| hdrs.contains(name))
})
}
Headers::Keep(ref hdrs) => raw
.aux_headers
.retain(|hdr, _| std::str::from_utf8(hdr).map_or(false, |name| hdrs.contains(name))),
Headers::Strip(ref hdrs) => {
for hdr in hdrs {
raw.aux_headers.remove(hdr.as_bytes());

View file

@ -1,4 +1,3 @@
use indexmap::IndexSet;
use crate::colors::AlphaOptim;
use crate::colors::ColorType;
use crate::evaluate::Evaluator;
@ -7,6 +6,7 @@ use crate::png::scan_lines::ScanLine;
use crate::png::PngImage;
#[cfg(not(feature = "parallel"))]
use crate::rayon::prelude::*;
use indexmap::IndexSet;
#[cfg(feature = "parallel")]
use rayon::prelude::*;
use std::sync::Arc;

View file

@ -1,7 +1,7 @@
use crate::colors::{BitDepth, ColorType};
use crate::headers::IhdrData;
use crate::png::PngImage;
use indexmap::map::{IndexMap, Entry::*};
use indexmap::map::{Entry::*, IndexMap};
use rgb::RGBA8;
use std::borrow::Cow;

View file

@ -437,7 +437,6 @@ fn zopfli_mode() {
);
}
#[test]
fn libdeflater_mode() {
let input = PathBuf::from("tests/files/zopfli_mode.png");